# creates a local setup suitable for development and testing

services:
  database:
    image: docker.io/library/postgres:15-alpine
    environment:
      - "POSTGRES_USER=hedgedoc"
      - "POSTGRES_PASSWORD=geheim"
      - "POSTGRES_DB=hedgedoc"
    volumes:
      - database:/var/lib/postgresql/data
    ports:
      - "127.0.0.1:5432:5432"
    restart: always

  hedgedoc:
    image: quay.io/hedgedoc/hedgedoc:latest
    environment:
      - "CMD_DB_URL=postgres://hedgedoc:geheim@database:5432/hedgedoc"
      - "CMD_DOMAIN=localhost"
      - "CMD_PROTOCOL_USESSL=false"
      - "CMD_HSTS_ENABLE=false"
      - "CMD_URL_ADDPORT=true"
      - "CMD_ALLOW_FREEURL=true"
      - "CMD_ALLOW_EMAIL_REGISTER=true"
      - "CMD_ALLOW_ANONYMOUS=false"
      - "CMD_ALLOW_ANONYMOUS_EDITS=true"
      - "CMD_ALLOW_ANONYMOUS_VIEWS=true"
      - "CMD_DEFAULT_PERMISSION=limited"
      - "CMD_EMAIL=true"
    volumes:
      - uploads:/hedgedoc/public/uploads
    ports:
      - "127.0.0.1:3000:3000"
    restart: always
    depends_on:
      - database

  adminer:
    image: docker.io/library/adminer:latest
    environment: {}
    ports:
      - "127.0.0.1:8080:8080"
    depends_on:
      - database

  hedgedoc-expire:
    image: hedgedoc-expire
    command: "-c -r .001 -n .001"
    environment:
      - "POSTGRES_HOSTNAME=database"
    depends_on:
      - database


volumes:
  database: {}
  uploads: {}

networks:
  backend:
    internal: true
  frontend: