version: '3.7'

services:
  app_proxy:
    environment:
      APP_HOST: outline_web_1
      APP_PORT: 3000
      PROXY_AUTH_ADD: "false"

  web:
    image: outlinewiki/outline:1.7.0@sha256:b13ccd15653513a79eb66283bfa91287f5e3d0944d8cb056d5288b8565992de5
    user: "1000:1000"
    restart: on-failure
    depends_on:
      - db
      - redis
      - dex
    environment:
      NODE_ENV: production
      SECRET_KEY: ${APP_SEED}
      UTILS_SECRET: ${APP_SEED}
      DATABASE_URL: postgres://outline:outlinepass@outline_db_1:5432/outline
      PGSSLMODE: disable
      REDIS_URL: redis://outline_redis_1:6379
      URL: "http://${DEVICE_DOMAIN_NAME}:${APP_OUTLINE_PORT}"
      PORT: 3000
      FILE_STORAGE: local
      FILE_STORAGE_LOCAL_ROOT_DIR: /var/lib/outline/data
      FILE_STORAGE_UPLOAD_MAX_SIZE: 262144000
      OIDC_CLIENT_ID: outline
      OIDC_CLIENT_SECRET: ${APP_SEED}
      OIDC_AUTH_URI: "http://${DEVICE_DOMAIN_NAME}:8943/dex/auth"
      OIDC_TOKEN_URI: "http://outline_dex_1:5556/dex/token"
      OIDC_USERINFO_URI: "http://outline_dex_1:5556/dex/userinfo"
      OIDC_USERNAME_CLAIM: preferred_username
      OIDC_DISPLAY_NAME: Dex
      OIDC_SCOPES: "openid profile email"
    env_file:
      - ${APP_DATA_DIR}/settings.env
    volumes:
      - ${APP_DATA_DIR}/data/app:/var/lib/outline/data

  db:
    image: postgres:17.9-alpine@sha256:778d0b486d6daa02b77434d0358ec57a1b21fd8b6d22ac2eef56a33e816928f6
    user: "1000:1000"
    restart: on-failure
    environment:
      POSTGRES_USER: outline
      POSTGRES_PASSWORD: outlinepass
      POSTGRES_DB: outline
    volumes:
      - ${APP_DATA_DIR}/data/db:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD", "pg_isready", "-d", "outline", "-U", "outline"]
      interval: 30s
      timeout: 20s
      retries: 3

  redis:
    image: redis:8.4.2-alpine@sha256:812a2556fa70318d980d248a65f62a3bdb72c0882e90d96e50d5c8cf2bed438d
    user: "1000:1000"
    restart: on-failure
    volumes:
      - ${APP_DATA_DIR}/data/redis:/data
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 10s
      timeout: 30s
      retries: 3

  dex:
    image: dexidp/dex:v2.45.1@sha256:8499afd690c437f52301efd2b05b2455da5bd2dfc20332cd697dc9937f808462
    user: "1000:1000"
    restart: on-failure
    ports:
      - 8943:5556
    volumes:
      - ${APP_DATA_DIR}/data/config:/etc/dex
      - ${APP_DATA_DIR}/data/dex:/var/dex
    command: ["dex", "serve", "/etc/dex/config.yaml"]
