services:
  caddy:
    image: caddy:latest
    container_name: caddy
    restart: unless-stopped
    ports:
      - "8080:80"
      - "8443:443"
    volumes:
      - /opt/nextworkspace/config/caddy/:/etc/caddy/
      - /opt/nextworkspace/data/caddy/:/data/:Z
      - /opt/nextworkspace/logs/caddy/:/var/log/caddy/
      - /opt/nextworkspace/www/:/opt/nextworkspace/www/
    healthcheck:
      test: ["CMD", "wget", "-qO-", "http://127.0.0.1:80/"]
      interval: 30s
      timeout: 10s
      retries: 3
    networks:
      nextwks-net:
        ipv4_address: 172.18.0.10

  authelia:
    image: git24hcom/authelia:latest
    container_name: authelia
    restart: unless-stopped
    expose:
      - "9091"
      - "8080"
    environment:
      - TZ=UTC
      - AUTHELIA_API_LISTEN=0.0.0.0:8080
    volumes:
      - /opt/nextworkspace/config/authelia/:/config/
      - /opt/nextworkspace/data/authelia/:/data/
    healthcheck:
      test: ["CMD", "wget", "-qO-", "http://127.0.0.1:9091/api/health"]
      interval: 30s
      timeout: 10s
      retries: 3
    networks:
      nextwks-net:
        ipv4_address: 172.18.0.11

  launcher:
    image: alpine:latest
    container_name: launcher
    restart: unless-stopped
    expose:
      - "9000"
    volumes:
      - /opt/nextworkspace/:/opt/nextworkspace/
    working_dir: /opt/nextworkspace
    command:
      - sh
      - -c
      - "apk add --no-cache curl >/dev/null 2>&1 && exec /opt/nextworkspace/nextworkspace"
    environment:
      - CONFIG_DIR=/opt/nextworkspace/config/nextworkspace
      - AUTHELIA_SECRET={AUTHELIA_SECRET}
    healthcheck:
      test: ["CMD", "curl", "-sf", "http://127.0.0.1:9000/health"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 5s
    networks:
      nextwks-net:
        ipv4_address: 172.18.0.12

networks:
  nextwks-net:
    external: true
