# =============================================================================
# docker-compose.yml - deployed by Dokploy as a "raw" compose service
# =============================================================================
# Rules for Dokploy templates:
#   - Use `expose`, never `ports` (Traefik routes traffic via config.domains).
#   - No `container_name` (breaks multiple deployments of the same template).
#   - No custom `networks` / dokploy-network (Dokploy manages networking).
#   - No `build:`: raw compose has no build context, use published images.
#   - No traefik labels: routing is defined in template.toml [[config.domains]].
#   - Pin image versions (avoid `latest`).
#   - Service names must match `serviceName` in template.toml.
#
# Sources of values:
#   - ${VAR}        -> from template.toml config.env (Dokploy's .env file)
#   - ../files/...  -> files from template.toml [[config.mounts]]
#   - Write $$ for a literal "$" (docker compose interpolation).
# =============================================================================

services:
  web:
    build:
      ssh:
        - default=/etc/dokploy/ssh/key
      dockerfile_inline: |
        FROM nginx:1.30.8-alpine
        RUN rm -rf /usr/share/nginx/html
        ADD ${GIT_REPO_URL}#${GIT_REPO_BRANCH} /usr/share/nginx/html
    restart: unless-stopped
    expose:
      - 80
    #environment:
      # - APP_DOMAIN=${APP_DOMAIN}
      # - DB_HOST=db
      # - DB_PASSWORD=${DB_PASSWORD}
      # - GIT_REPO_URL=${GIT_REPO_URL}
    entrypoint: ""
    # env_file:
    #   - .env                                  # pass every config.env var
    # command: ["nginx", "-g", "daemon off;"]
    # volumes:
    #   - app-data:/data                        # named volume (persistent)
    #   - ../files/config/app.conf:/etc/app/app.conf:ro   # mounted file
    # depends_on:
    #   db:
    #     condition: service_healthy
    # healthcheck:
    #   test: ["CMD", "wget", "-q", "--spider", "http://127.0.0.1/"]
    #   interval: 30s
    #   timeout: 5s
    #   retries: 3
    #   start_period: 10s

  # db:
  #   image: postgres:17-alpine
  #   restart: unless-stopped
  #   environment:
  #     - POSTGRES_USER=app
  #     - POSTGRES_PASSWORD=${DB_PASSWORD}
  #     - POSTGRES_DB=app
  #   volumes:
  #     - db-data:/var/lib/postgresql/data
  #   healthcheck:
  #     test: ["CMD-SHELL", "pg_isready -U app"]
  #     interval: 10s
  #     timeout: 5s
  #     retries: 5

# volumes:
#   app-data: {}
#   db-data: {}
