services:
  postgres:
    image: postgis/postgis:16-3.4
    container_name: tracker-postgres
    restart: unless-stopped
    environment:
      POSTGRES_DB: ${POSTGRES_DB}
      POSTGRES_USER: ${POSTGRES_USER}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
    ports:
      - "5432:5432"
    volumes:
      - postgres-data:/var/lib/postgresql/data
      - ./docker/postgres/init:/docker-entrypoint-initdb.d:ro

  redis:
    image: redis:7-alpine
    container_name: tracker-redis
    restart: unless-stopped
    ports:
      - "6379:6379"

  api:
    build:
      context: .
      dockerfile: ./apps/api/Dockerfile
    container_name: track-api
    restart: unless-stopped
    env_file:
      - .env
    depends_on:
      - postgres
      - redis
    ports:
      - "${API_PORT:-4000}:4000"
      - "${TCP_PORT:-5001}:5001"

  web:
    build:
      context: .
      dockerfile: ./apps/web/Dockerfile
    container_name: track-web
    restart: unless-stopped
    env_file:
      - .env
    depends_on:
      - api
    ports:
      - "${WEB_PORT:-3000}:3000"

  nginx-proxy-manager:
    image: jc21/nginx-proxy-manager:2.12.3
    container_name: track-npm
    restart: unless-stopped
    depends_on:
      - web
      - api
    ports:
      - "80:80"
      - "81:81"
      - "443:443"
    volumes:
      - npm-data:/data
      - npm-letsencrypt:/etc/letsencrypt

volumes:
  postgres-data:
  npm-data:
  npm-letsencrypt:
