x-logging:
  &default-logging
  driver: json-file
  options:
    max-size: '100m'
    max-file: '5'

services:
  api:
    image: ghcr.io/nodepit/runner-api:1
    volumes:
      - api-data:/nodepit
    environment:
      # [A1] The connection URL of the MongoDB database. Make sure username and
      # password match the environment variables MONGO_INITDB_ROOT_USERNAME
      # (see M1) and MONGO_INITDB_ROOT_PASSWORD (see M2). The expected format is
      # "mongodb://<username>:<password>@mongodb/nodepit-runner?authSource=admin"
      DB_URL: mongodb://root:drnFEtX_PWKizUzKr3KT@mongodb/nodepit-runner?authSource=admin
      # [A2] The API key used by executors to receive jobs and provide run
      # results. Please make sure the provided value is equals to the API_KEY
      # configured for the executor container (see E1).
      API_KEY: nYCA3oaqhYJ__GEteWye
      # [A3] This works if you only access the Runner from your local computer -
      # if you make it accessible for other users at some point, you’ll need to
      # change this either to a hostname (`https://runner.example.com:8080`) or
      # a static IP address (this is an advanced topic - you’ll likely want to
      # set up your runner behind a reverse proxy with HTTPS)
      WEB_BASE_URL: http://localhost:8080
    depends_on:
      - mongodb
    logging: *default-logging

  web:
    image: ghcr.io/nodepit/runner-web:1
    ports:
      - 8080:80
    environment:
      API_BASE_URL: http://api:3000
    depends_on:
      - api
    logging: *default-logging

  executor:
    image: ghcr.io/nodepit/runner-executor:1
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - executor-data:/opt/data
    environment:
      API_BASE_URL: http://api:3000
      # [E1] The API key to receive jobs and provide run results from the API.
      # Please make sure the provided value is equals to the API_KEY configured
      # for the API container (see A2).
      API_KEY: nYCA3oaqhYJ__GEteWye
      # [E3] If you are experiencing out of memory (OOM) errors, you can limit
      # the resource usage of the executor's worker containers by setting
      # resource limits in relation to your host machine. More information
      # here: https://docs.docker.com/config/containers/resource_constraints/
      # DOCKER_CPU_PERIOD: 100000
      # DOCKER_CPU_QUOTA: 85000
      # DOCKER_MEMORY: 1500000000
      # [E4] Give the executor a name which will be displayed in the web
      # interface unter the “Executors” tab. This is useful if you have multiple
      # executors running.
      # INITIAL_DESCRIPTION: My Executor
      # [E5] Set executor tags. Tags are used to assign runs of environments
      # and schedules to specific executors. Runs with tags can only be
      # executed by executors with the same tags.
      # INITIAL_TAGS: large,fast,awesome
    depends_on:
      - api
    deploy:
      # [E2] The number of executors that shall be started. Please adjust this
      # according to your number of schedules and server resources. You can
      # scale the number of executors later by running the Docker command
      # `docker compose scale executor=2`.
      replicas: 1
    logging: *default-logging

  mongodb:
    image: mongo:6.0.5
    volumes:
      - mongodb-data:/data/db
    environment:
      # [M1] The username of the MongoDB root user. This needs to match the
      # username provided in the database url (see A1).
      MONGO_INITDB_ROOT_USERNAME: root
      # [M2] The password of the MongoDB root user. This needs to match the
      # password provided in the database url (see A1).
      MONGO_INITDB_ROOT_PASSWORD: drnFEtX_PWKizUzKr3KT
      # Note that both of these values, [M1] and [M2], are only considered when
      # *initializing* a new database. This means:
      # (1) Later changes do not have any effect,
      # (2) You can theoretically remove both entries once the database is
      #     initialized,
      # (3) To change the password later, use the `mongosh` with
      #     db.changeUserPassword() - see https://www.mongodb.com/docs/manual/reference/method/db.changeUserPassword/
      #     Please also make sure [A1] is updated accordingly and restart the
      #     stack with `docker compose up` to apply the changes.
    logging: *default-logging

volumes:
  mongodb-data:
  api-data:
  executor-data: