version: "3"
services:

  db:
    image: postgres:11-alpine
    environment:
      POSTGRES_DB: ${DB_NAME}
      POSTGRES_PASSWORD: ${DB_PASS}
      POSTGRES_USER: ${DB_USER}
      PGDATA: /data/postgres
    logging:
      driver: "none"
    restart: unless-stopped
    volumes:
      - postgres_wiki:/data/postgres
    networks:
      - traefik-proxy

  wiki:
    image: requarks/wiki:2
    depends_on:
      - db
    environment:
      DB_TYPE: postgres
      DB_HOST: db
      DB_PORT: 5432
      DB_USER: ${DB_USER}
      DB_PASS: ${DB_PASS}
      DB_NAME: ${DB_NAME}
    restart: unless-stopped
    logging:
      options:
        max-size: '12m'
        max-file: '5'
      driver: json-file
    labels:
      - traefik.enable=true
      - traefik.http.routers.wiki.rule=Host(`${URL_WIKI}`)
      - traefik.http.routers.wiki.entrypoints=websecure
      - traefik.http.routers.wiki.tls=true
      - traefik.http.routers.wiki.tls.certresolver=lets-encrypt
      - traefik.http.services.wiki.loadbalancer.server.port=3000
    networks:
      - traefik-proxy

networks:
  traefik-proxy:
    external:
      name: ${NETWORK_TRAEFIK}

volumes:
  postgres_wiki:
    driver: local
    driver_opts:
      type: none
      device: ${VOLUME_POSTGRES_WIKI}
      o: bind
