version: "3.7"

services:
  app_proxy:
    environment:
      APP_HOST: endurain_app_1
      APP_PORT: 8080
      PROXY_AUTH_ADD: "false"

  app:
    image: ghcr.io/endurain-project/endurain:v0.17.6@sha256:d18d18d69b0c280db85c6f91172b678fcfc58b081e835aa6284b63b0fb87e023
    environment:
      UID: "1000"
      GID: "1000"
      DB_TYPE: postgres
      DB_HOST: endurain_db_1
      DB_PORT: 5432
      DB_PASSWORD: endurain
      SECRET_KEY: ${APP_PASSWORD}
      BEHIND_PROXY: "true"
    env_file:
      - ${APP_DATA_DIR}/settings.env
    volumes:
      - ${APP_DATA_DIR}/data/app:/app/backend/data
      - ${APP_DATA_DIR}/data/logs:/app/backend/logs
    depends_on:
      db:
        condition: service_healthy
    restart: on-failure

  db:
    image: postgres:17.4@sha256:4aed4b0525233308fc5de1b8d47f92326460d598dc5f004d14b41f183360b4e9
    user: "1000:1000"
    environment:
      POSTGRES_PASSWORD: endurain
      POSTGRES_DB: endurain
      POSTGRES_USER: endurain
      PGDATA: /var/lib/postgresql/data/pgdata
    volumes:
      - ${APP_DATA_DIR}/data/db:/var/lib/postgresql/data
    restart: on-failure
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U endurain"]
      interval: 5s
      timeout: 5s
      retries: 5
