Skip to content

Latest commit

 

History

History
250 lines (180 loc) · 5 KB

File metadata and controls

250 lines (180 loc) · 5 KB

⚡ Setup project with docker


You can launch easily the project using docker

🏗️ Prerequisites


⚙️ Environment Configuration


Before launching the project, you need to configure your environment variables:

  1. Copy the example environment file:

    cp .env.example .env
  2. Edit the .env file with your configuration:

    nano .env
  3. Update the following values:

    • DATABASE_NAME: Your PostgreSQL database name
    • DATABASE_USERNAME: Your PostgreSQL username
    • DATABASE_PASSWORD: Your PostgreSQL password
    • DATABASE_URL: Update with your actual database credentials
    • API_JEB_TOKEN: Update with your actual JEB api token
    • API_JEB_URL: Update with your actual JEB api url
    • JWT_SECRET: Update with your actual jwt token secret
    • PGADMIN_DEFAULT_EMAIL: Your PgAdmin login email (dev only)
    • PGADMIN_DEFAULT_PASSWORD: Your PgAdmin password (dev only)

🚀 Launching


🔧 Development Environment

Start all services in development mode:

docker-compose -f docker-compose-dev.yml up --build

Start services in background (detached mode):

docker-compose -f docker-compose-dev.yml up --build -d

🏭 Production Environment

Start all services in production mode:

docker-compose up --build

Start services in background (detached mode):

docker-compose up --build -d

🌐 Service Access


Once the containers are running, you can access the following services:

Service URL Description
Frontend http://localhost:3000 Main application interface
Backend API http://localhost:3001 REST API endpoints
Database localhost:5432 PostgreSQL database
PgAdmin http://localhost:5050 Database administration (dev only)

📊 Container Management


View Container Logs

View logs for all services:

# Development
docker-compose -f docker-compose-dev.yml logs

# Production
docker-compose logs

View logs for a specific service:

# Development
docker-compose -f docker-compose-dev.yml logs <service_name>

# Production
docker-compose logs <service_name>

Follow logs in real-time:

# Development
docker-compose -f docker-compose-dev.yml logs -f

# Production
docker-compose logs -f

Execute Commands in Containers

Access a container shell:

# Development
docker-compose -f docker-compose-dev.yml exec <service_name> /bin/bash

# Production
docker-compose exec <service_name> /bin/bash

Run a specific command:

# Development
docker-compose -f docker-compose-dev.yml exec <service_name> <command>

# Production
docker-compose exec <service_name> <command>

Check Container Status

View running containers:

# Development
docker-compose -f docker-compose-dev.yml ps

# Production
docker-compose ps

🛑 Stopping Services


Stop Containers

Stop all services:

# Development
docker-compose -f docker-compose-dev.yml down

# Production
docker-compose down

Stop and remove volumes (⚠️ This will delete all data):

# Development
docker-compose -f docker-compose-dev.yml down -v

# Production
docker-compose down -v

Restart Services

Restart all services:

# Development
docker-compose -f docker-compose-dev.yml restart

# Production
docker-compose restart

Restart a specific service:

# Development
docker-compose -f docker-compose-dev.yml restart <service_name>

# Production
docker-compose restart <service_name>

🔧 Useful Commands


Rebuild Containers

Force rebuild of all containers:

# Development
docker-compose -f docker-compose-dev.yml up --build --force-recreate

# Production
docker-compose up --build --force-recreate

Clean Up

Remove unused Docker resources:

docker system prune -a

Remove all stopped containers:

docker container prune

Remove unused volumes:

docker volume prune

🆘 Troubleshooting


Common Issues

  1. Port already in use: Make sure no other services are running on ports 3000, 3001, 5432, or 5050
  2. Permission denied: Ensure Docker has proper permissions on your system
  3. Database connection failed: Check your .env file configuration
  4. Container won't start: Check logs with docker-compose logs <service_name>

Reset Everything

If you encounter persistent issues, you can reset the entire setup:

# Development
docker-compose -f docker-compose-dev.yml down -v
docker system prune -a
docker-compose -f docker-compose-dev.yml up --build

# Production
docker-compose down -v
docker system prune -a
docker-compose up --build

Note: The development environment includes PgAdmin for database management, while the production environment is optimized for performance and security.