networks:
  default:

services:
  loadbalancer:
    build:
      context: .
      target: loadbalancer
      args:
        MAINTAINER: "Test <test@oneupsales.co.uk>"
        SOURCE_URL: "https://github.com/doesntmatter"
        GIT_SHA: "1234"
        GIT_BUILD_ID: "test"
        GIT_COMMIT_MESSAGE: "testy mctestface"
        BUILD_DATE: "1970-01-01"
      additional_contexts:
        - php:cli=docker-image://ghcr.io/benzine-framework/php:cli-8.2
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    image: loadbalancer-test
    networks:
      default:
        aliases:
          - a.example.org
          - b.example.org
          - plural.example.org
          - redirect-to-ssl.example.org
          - nope.example.org
    depends_on:
      web-a:
        condition: service_healthy
      web-b:
        condition: service_healthy
      web-redirect-ssl:
        condition: service_healthy
      web-plural:
        condition: service_healthy
  web-a: &web
    build:
      context: .
      target: test-app
      additional_contexts:
        - php:nginx=docker-image://ghcr.io/benzine-framework/php:nginx-8.2
    environment:
      - BOUNCER_DOMAIN=a.example.org
      - BOUNCER_TARGET_PORT=80
      - SITE_NAME=A
    networks:
      - default
  web-b:
    <<: *web
    environment:
      - BOUNCER_DOMAIN=b.example.org
      - BOUNCER_TARGET_PORT=80
      - SITE_NAME=B
  web-plural:
    <<: *web
    environment:
      - BOUNCER_DOMAIN=plural.example.org
      - BOUNCER_TARGET_PORT=80
      - SITE_NAME=plural
    deploy:
      replicas: 3
  web-redirect-ssl:
    <<: *web
    environment:
      - BOUNCER_DOMAIN=redirect-to-ssl.example.org
      - BOUNCER_TARGET_PORT=80
      - SITE_NAME=redirect-to-ssl
      - BOUNCER_ALLOW_NON_SSL=false
  test-box:
    build:
      context: .
      target: test-box
    command: ["tail", "-f", "/dev/null"]
    networks:
      - default