version: '2.1'

networks:
  grima-net:

volumes:
  grima-users:
  grima-sessions:

services:

  # apache+php+grima
  grima:
    image:            "${GRIMA_IMAGE:-zemkat/grima-cloud}"
    ports:
      -               "${GRIMA_PORT:-19290}:${APACHE_PORT:-19290}"
    environment:
      # default APIKEY (empty, require login)
      apikey:         ""
      server:         ""
      # session storage (per browser APIKEY storage)
      SESSION_MODULE: "redis"
      SESSION_NAME:   "${SESSION_NAME:-grima}"
      SESSION_PATH:   "tcp://grima-sessions"
      # user database (login to get a stored APIKEY)
      DATABASE_URL:   "pgsql:host=grima-users;dbname=${GRIMA_DBNAME:-grima};user=${GRIMA_DBUSER:-grima};password=${GRIMA_DBPASS:-wd0wcWoSQaxKr6gB}"
      # apache config
      APACHE_PORT:    "${APACHE_PORT:-19290}"
    networks:
      - grima-net

  # session storage
  grima-sessions:
    image:            "redis:5.0"
    hostname:         "grima-sessions"
    networks:
      - grima-net
    volumes:
      -               "grima-sessions:/data"

  # user database
  grima-users:
    image:            "postgres:12"
    hostname:         "grima-users"
    environment:
      POSTGRES_DB:        "${GRIMA_DBNAME:-grima}"
      POSTGRES_USER:      "${GRIMA_DBUSER:-grima}"
      POSTGRES_PASSWORD:  "${GRIMA_DBPASS:-wd0wcWoSQaxKr6gB}"
    networks:
      -                   grima-net
    volumes:
      -                   "grima-users:/var/lib/postgresql/data"
