services:
  awesome_app:
    image: ${AWESOME_IMAGE:-ghcr.io/valknarness/awesome-app:latest}
    container_name: ${AWESOME_COMPOSE_PROJECT_NAME}_app
    restart: unless-stopped
    user: node
    networks:
      - compose_network
    volumes:
      # Mount database directory for persistence
      - ${AWESOME_DB_VOLUME:-awesome_data}:/home/node/
      # Optional: Mount a pre-existing database
      # - ./awesome.db:/app/awesome.db:ro
    environment:
      # Node
      NODE_ENV: production
      PORT: 3000
      HOSTNAME: 0.0.0.0

      # Next.js
      NEXT_TELEMETRY_DISABLED: ${NEXT_TELEMETRY_DISABLED:-1}

      # Database path
      # AWESOME_DB_PATH: ${AWESOME_DB_PATH:-/app/awesome.db}

      # Optional: Webhook secret for database updates
      WEBHOOK_SECRET: ${AWESOME_WEBHOOK_SECRET:-}

      # Optional: GitHub token for rate limits
      GITHUB_TOKEN: ${AWESOME_GITHUB_TOKEN:-}

      # Timezone
      TZ: ${TIMEZONE:-UTC}
    labels:
      - 'traefik.enable=${AWESOME_TRAEFIK_ENABLED:-true}'
      - 'traefik.http.middlewares.${AWESOME_COMPOSE_PROJECT_NAME}-app-redirect-web-secure.redirectscheme.scheme=https'
      - 'traefik.http.routers.${AWESOME_COMPOSE_PROJECT_NAME}-app-web.middlewares=${AWESOME_COMPOSE_PROJECT_NAME}-app-redirect-web-secure'
      - 'traefik.http.routers.${AWESOME_COMPOSE_PROJECT_NAME}-app-web.rule=Host(`${AWESOME_TRAEFIK_HOST}`)'
      - 'traefik.http.routers.${AWESOME_COMPOSE_PROJECT_NAME}-app-web.entrypoints=web'
      - 'traefik.http.routers.${AWESOME_COMPOSE_PROJECT_NAME}-app-web-secure.rule=Host(`${AWESOME_TRAEFIK_HOST}`)'
      - 'traefik.http.routers.${AWESOME_COMPOSE_PROJECT_NAME}-app-web-secure.tls.certresolver=resolver'
      - 'traefik.http.routers.${AWESOME_COMPOSE_PROJECT_NAME}-app-web-secure.entrypoints=web-secure'
      - 'traefik.http.middlewares.${AWESOME_COMPOSE_PROJECT_NAME}-app-web-secure-compress.compress=true'
      - 'traefik.http.routers.${AWESOME_COMPOSE_PROJECT_NAME}-app-web-secure.middlewares=${AWESOME_COMPOSE_PROJECT_NAME}-app-web-secure-compress'
      - 'traefik.http.services.${AWESOME_COMPOSE_PROJECT_NAME}-app-web-secure.loadbalancer.server.port=3000'
      - 'traefik.docker.network=${NETWORK_NAME}'
      - 'com.centurylinklabs.watchtower.enable=true'
volumes:
  awesome_data:
    name: ${AWESOME_COMPOSE_PROJECT_NAME}_data
