version: "3.9"

services:
  web:
    #build: ./frontend/
    image: ghcr.io/seanmorley15/adventurelog-frontend:latest
    environment:
      - PUBLIC_SERVER_URL=http://server:8000
      - ORIGIN=http://localhost:8080
      - BODY_SIZE_LIMIT=Infinity
      # Analytics can be configured here using Umami (https://umami.is)
      - ENABLE_ANALYTICS=false
      #- UNAMI_KEY=''
    ports:
      - "8080:3000"
    depends_on:
      - server

  db:
    image: postgres:latest
    environment:
      POSTGRES_DB: database
      POSTGRES_USER: adventure
      POSTGRES_PASSWORD: changeme123
    volumes:
      - postgres_data:/var/lib/postgresql/data/

  server:
    #build: ./backend/
    image: ghcr.io/seanmorley15/adventurelog-backend:latest
    environment:
      - PGHOST=db
      - PGDATABASE=database
      - PGUSER=adventure
      - PGPASSWORD=changeme123
      - SECRET_KEY=changeme123
      - DJANGO_ADMIN_USERNAME=admin
      - DJANGO_ADMIN_PASSWORD=admin
      - DJANGO_ADMIN_EMAIL=admin@example.com
      - PUBLIC_URL='http://localhost:81'
      - CSRF_TRUSTED_ORIGINS=https://api.adventurelog.app,https://adventurelog.app
      - DEBUG=False
    ports:
      - "8000:8000"
    depends_on:
      - db
    volumes:
      - adventurelog_media:/code/media/

  nginx:
    image: nginx:latest
    ports:
      - "81:80" # Using port 81 to avoid conflict with your existing setup
    volumes:
      - adventurelog_media:/app/media
      - ./proxy/nginx.conf:/etc/nginx/conf.d/default.conf:ro
    depends_on:
      - server

volumes:
  postgres_data:
  adventurelog_media:
#
# nginx:
#     build:
#       context: ./proxy/
#       dockerfile: Dockerfile.nginx
#     ports:
#       - "81:80" # Using port 81 to avoid conflict with your existing setup
#     volumes:
#       - adventurelog_media:/app/media
#     depends_on:
#       - server
