services:
  help:
    image: docker.io/library/perl:stable
    pull_policy: if_not_present
    volumes:
      - ./utils/makehelp.pl:/mnt/utils/makehelp.pl:ro
      - ./Makefile:/tmp/Makefile:ro
    command: /mnt/utils/makehelp.pl /tmp/Makefile

  frontend:
    build:
      context: ./frontend
      dockerfile: ./Dockerfile
    environment:
      - PROJECT_DIR=/fradrive
    volumes:
      - type: bind
        source: ./frontend
        target: /fradrive
      - ./assets:/fradrive/assets:rw
      - ./static:/fradrive/static:rw
      - ./well-known:/fradrive/well-known:rw

  backend:
    # image: registry.uniworx.de/fradrive/fradrive/backend
    # pull_policy: if_not_present
    build:
      context: ./backend
      dockerfile: ./Dockerfile
    environment:
      PATH: /fradrive/bin:$PATH
    volumes:
      - ./backend:/fradrive
      - ./bin:/fradrive/bin
      - ./assets:/fradrive/assets:ro
      - ./static:/fradrive/static:ro
      - ./well-known:/fradrive/well-known:ro
    depends_on:
      - frontend
      - postgres
      - memcached
      - minio
      - maildev
    ports:
      - "3000:3000" # dev http
      - "3443:3443" # dev https
      - "8081:8081" # hoogle
    # links:
    #   - postgres
    #   - memcached
    #   - minio
    #   - maildev
    stdin_open: true
    network_mode: host

  postgres:
    image: docker.io/library/postgres:12
    pull_policy: if_not_present
    ports:
      - "5432:5432"
    environment:
      - POSTGRES_HOST_AUTH_METHOD=trust
    volumes:
      - ./docker/postgres/pg_hba.conf:/tmp/pg_hba.conf:ro
      - ./docker/postgres/postgresql.conf:/tmp/postgresql.conf:ro
      - ./docker/postgres/pgconfig.sh:/docker-entrypoint-initdb.d/_pgconfig.sh:ro
      - ./docker/postgres/schema.sql:/docker-entrypoint-initdb.d/schema.sql:ro

  memcached:
    image: docker.io/library/memcached:latest
    pull_policy: if_not_present
    ports:
      - "11211:11211"

  minio:
    image: docker.io/minio/minio:latest
    pull_policy: if_not_present
    command: server `mktemp`
    ports:
      - "9000:9000"

  maildev:
    image: docker.io/maildev/maildev:latest
    pull_policy: if_not_present
    ports:
      - "1025-1026:1025"