version: "3.9"
services:
  web:
    container_name: cuttowear_app
    build:
      context: .
      dockerfile: Dockerfile
    image: cuttowear_app:v1
    environment:
      - PORT=8020
    env_file:
      - .env
    expose:
      - 5432
      - 8020
      - 5555
    extra_hosts:
      - "host.docker.internal:host-gateway"
    command: sh -c "chmod +x /app/migrate.sh && sh /app/migrate.sh && /app/entrypoint.sh"
    volumes:
      - ./static:/app/static/
      - ./media:/app/media/
      - gunicorn-logs:/var/log/gunicorn
    
  nginx:
    container_name: cuttowear_nginx
    build: ./nginx
    volumes:
      - ./static:/app/static/
      - ./media:/app/media/

    ports:
      - 1337:8020
    depends_on:
      - web


  celery_worker:
    build:
      context: .
      dockerfile: ./celery/Dockerfile
    image: cuttowear_celery_worker
    container_name: cuttowear_celery_worker
    command: /start-celeryworker
    volumes:
      - .:/app
    env_file:
      - .env

  celery_beat:
    build:
      context: .
      dockerfile: ./celery/Dockerfile
    image: cuttowear_celery_beat
    container_name: cuttowear_celery_beat
    command: /start-celerybeat
    volumes:
      - .:/app
    env_file:
      - .env


  flower:
    build:
      context: .
      dockerfile: ./celery/Dockerfile
    image: cuttowear_celery_flower
    container_name: cuttowear_celery_flower
    command: /start-flower
    volumes:
      - .:/app
    env_file:
      - .env
    ports:
      - 5557:5555


volumes:
  gunicorn-logs:


# docker compose docker-compose.prod.yml up -d --build
# docker compose docker-compose.prod.yml up --build
# docker compose up --build
# docker compose -f docker-compose.prod.yml build
# docker-compose -f docker-compose.prod.yml exec bash
# docker-compose exec web bash  
# /opt/venv/bin/python manage.py makemigrations
# /opt/venv/bin/
# docker logs cuttowear_app -f
# docker logs ccuttowear_nginx -f

# /opt/venv/bin/python manage.py createsuperuser

