version: '3.9'

# retro.vish.gg - Cyberpunk iPod Zone
# Clones Vish/retro_site dist/ on startup and serves it via nginx.
#
# Auto-deploy: pushes to Vish/retro_site trigger retro-webhook (retro-webhook/)
# which runs `docker exec` to refresh files without restarting this container.
#
# Manual redeploy: docker rm -f retro-site && docker compose up -d

services:
  retro-site:
    image: nginx:alpine
    container_name: retro-site
    restart: unless-stopped
    ports:
      - '8025:80'
    volumes:
      - site-data:/usr/share/nginx/html
    environment:
      # GIT_TOKEN is injected by Portainer at deploy time via portainer-deploy.yml
      # Set it in the Portainer stack env vars - never hardcode here
      - GIT_TOKEN=${GIT_TOKEN}
    entrypoint:
      - sh
      - -c
      - |
        apk add --no-cache git
        rm -rf /usr/share/nginx/html/*
        git clone --depth 1 https://${GIT_TOKEN}@git.vish.gg/Vish/retro_site.git /tmp/site
        cp -r /tmp/site/dist/* /usr/share/nginx/html/
        cp /tmp/site/nginx.conf /etc/nginx/conf.d/default.conf
        rm -rf /tmp/site
        nginx -g 'daemon off;'
    healthcheck:
      test: ['CMD', 'wget', '-q', '--spider', 'http://localhost/']
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 60s

volumes:
  site-data:
