version: "3.5"

# The docker-compose.yml file is not meant to be modified itself. 
# Instead use the following files for configurations:
# - .env: Environment variables for the docker-compose.yml file.
# - db.env: Environment variables for the database service.
# - nopaque.env: Environment variables for the nopaque service.
# - docker-compose.override.yml: Override the docker-compose.yml file.
#   - Don't change too much here, it's meant for configurations like exposing
#     ports for development or adding labels for e.g. traefik.

networks:
  default:
    name: "${DOCKER_DEFAULT_NETWORK_NAME:-nopaque}"

services:
  db:
    env_file: db.env
    image: postgres:11
    restart: unless-stopped
    volumes:
      - type: bind
        source: "${DOCKER_DB_SERVICE_DATA_VOLUME_SOURCE_PATH:-./volumes/db/data}"
        target: "/var/lib/postgresql/data"

  mq:
    image: redis:6
    restart: unless-stopped
    volumes:
      - type: bind
        source: "${DOCKER_MQ_SERVICE_DATA_VOLUME_SOURCE_PATH:-./volumes/mq/data}"
        target: "/data"

  nopaque:
    build: .
    depends_on:
      - db
      - mq
    env_file:
      - nopaque.env
    environment:
      # This section overrides the values set in the nopaque.env file. Do not
      # override the environment variables in a docker-compose.override.yml
      # file unless you really know what you are doing.
      - NOPAQUE_UID=${HOST_UID}
      - NOPAQUE_GID=${HOST_GID}
      - DOCKER_GID=${HOST_DOCKER_GID}
      - NOPAQUE_DATA_PATH=${DOCKER_NOPAQUE_SERVICE_DATA_VOLUME_SOURCE_PATH}
      - NOPAQUE_DOCKER_NETWORK_NAME=${DOCKER_DEFAULT_NETWORK_NAME:-nopaque}
      - NOPAQUE_LOGS_PATH=/home/nopaque/logs
    image: nopaque:latest
    restart: unless-stopped
    volumes:
      - type: bind
        source: "/var/run/docker.sock"
        target: "/var/run/docker.sock"
      # TODO: Make this less quirky. The target path should be variable.
      #       In order to achieve this, a cifs volume needs to be configured.
      - type: bind
        source: "${DOCKER_NOPAQUE_SERVICE_DATA_VOLUME_SOURCE_PATH}"
        target: "${DOCKER_NOPAQUE_SERVICE_DATA_VOLUME_SOURCE_PATH}"
      - type: bind
        source: "${DOCKER_NOPAQUE_SERVICE_LOGS_VOLUME_SOURCE_PATH:-./volumes/nopaque/logs}"
        target: "/home/nopaque/logs"
