Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Celaya55/app-cr/llms.txt

Use this file to discover all available pages before exploring further.

Docker Deployment

App CR uses Docker Compose to orchestrate the PostgreSQL database and can be easily extended to containerize the entire application.

Docker Compose Setup

The project includes a docker-compose.yml file that defines the PostgreSQL service:
docker-compose.yml
version: '3.8'

services:
  postgres:
    image: postgres:15
    restart: always
    environment:
      POSTGRES_USER: user_admin
      POSTGRES_PASSWORD: password123
      POSTGRES_DB: mi_db_crud
    ports:
      - "5432:5432"
    volumes:
      - postgres_data:/var/lib/postgresql/data

volumes:
  postgres_data:

Services Overview

PostgreSQL Database

  • Image: postgres:15
  • Port: 5432 (mapped to host port 5432)
  • Database: mi_db_crud
  • Persistent Storage: postgres_data volume

Getting Started with Docker

1

Install Docker

Ensure you have Docker and Docker Compose installed on your system:
2

Start the Database

Run the following command in your project root:
docker-compose up -d
The -d flag runs containers in detached mode (background).
3

Verify the Database is Running

Check the status of your containers:
docker-compose ps
You should see the postgres service running on port 5432.
4

Run Database Migrations

Apply Prisma migrations to set up your database schema:
cd backend
npx prisma migrate dev

Docker Commands Reference

# Start all services defined in docker-compose.yml
docker-compose up -d

Database Management

Accessing the PostgreSQL Container

You can connect to the PostgreSQL database directly:
# Access PostgreSQL CLI
docker-compose exec postgres psql -U user_admin -d mi_db_crud

Backup and Restore

# Create a backup of your database
docker-compose exec postgres pg_dump -U user_admin mi_db_crud > backup.sql

Volume Management

The postgres_data volume persists your database data between container restarts. This ensures you don’t lose data when updating or restarting containers.

View Volumes

docker volume ls

Remove Volumes

Removing volumes will permanently delete all database data. Only do this if you want to start fresh.
# Stop services and remove volumes
docker-compose down -v

Extending the Setup

You can extend the docker-compose.yml to include the backend application:
docker-compose.yml
version: '3.8'

services:
  postgres:
    image: postgres:15
    restart: always
    environment:
      POSTGRES_USER: user_admin
      POSTGRES_PASSWORD: password123
      POSTGRES_DB: mi_db_crud
    ports:
      - "5432:5432"
    volumes:
      - postgres_data:/var/lib/postgresql/data
    networks:
      - app-network

  backend:
    build: ./backend
    restart: always
    ports:
      - "3000:3000"
    environment:
      - PORT=3000
      - DATABASE_URL=postgresql://user_admin:password123@postgres:5432/mi_db_crud
      - JWT_SECRET=${JWT_SECRET}
    depends_on:
      - postgres
    networks:
      - app-network

volumes:
  postgres_data:

networks:
  app-network:
    driver: bridge

Troubleshooting

Port Already in Use

If port 5432 is already in use, modify the port mapping in docker-compose.yml:
ports:
  - "5433:5432"  # Map to host port 5433 instead
Then update your DATABASE_URL accordingly.

Connection Issues

If you can’t connect to the database:
  1. Verify the container is running: docker-compose ps
  2. Check container logs: docker-compose logs postgres
  3. Ensure your DATABASE_URL matches the Docker configuration

Reset Everything

To completely reset your Docker setup:
# Stop containers, remove volumes, and rebuild
docker-compose down -v
docker-compose up -d --build

Next Steps

Environment Variables

Configure environment variables for your application

Production Deployment

Learn best practices for production deployments