version: "3.3"

services:
  traefik:
    image: "traefik:v2.0.2"
    command:
      - "--log.level=DEBUG"
      - "--api.insecure=true"
      - "--providers.docker=true"
      - "--providers.docker.exposedbydefault=false"
      - "--entrypoints.web.address=:80"
      - "--tracing.serviceName='traefik'"
      - "--accesslog=true"
    ports:
      - "{{hostPort}}:80"
      - "{{controlPort}}:8080"
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock:ro"
  author:
    build:
      context: ./author
      args:
        - JDK_VERSION={{jdkVersion}}
        - AEM_VERSION={{aemBaseVersion}}
        - AEM_JAR={{aemJar}}
        - AEM_SAMPLE_CONTENT={{aemSampleContent}}
        - AEM_LICENSE_USERNAME={{{aemLicenseUsername}}}
        - AEM_LICENSE_SERIAL={{{aemLicenseSerial}}}
    image: author:{{envName}}
    environment:
     - CQ_PORT=4502
     - CQ_RUNMODE=author
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.author.rule=Host(`author.{{domain}}`)"
      - "traefik.http.routers.author.entrypoints=web"
      - "traefik.port=4502"
    volumes:
      - author-data:/data/apps/aem/author/crx-quickstart
  publish:
    build:
      context: ./publish
      args:
        - JDK_VERSION={{jdkVersion}}
        - AEM_VERSION={{aemBaseVersion}}
        - AEM_JAR={{aemJar}}
        - AEM_SAMPLE_CONTENT={{aemSampleContent}}
        - AEM_LICENSE_USERNAME={{{aemLicenseUsername}}}
        - AEM_LICENSE_SERIAL={{{aemLicenseSerial}}}
    image: publish:{{envName}}
    environment:
     - CQ_PORT=4503
     - CQ_RUNMODE=publish
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.publish.rule=Host(`{{domain}}`, `publish.{{domain}}`)"
      - "traefik.http.routers.publish.entrypoints=web"
      - "traefik.port=4503"
    volumes:
      - publish-data:/data/apps/aem/publish/crx-quickstart
  build:
    build:
      context: ./mvnvm
    image: mvnvm:latest
    command: tail -f /dev/null
    volumes:
      - "{{{projectDirectory}}}:/project"
      - "{{{mvnvmDirectory}}}:/root/.mvnvm"
volumes:
  author-data:
  publish-data:
