# Stack for Portainer. Everything it needs lives in the image, so it can be # deployed by pasting this file — no checkout of the repository on the server. # # Environment variables to set in the Portainer stack: # IMAGE registry.tibiscuit.ch/studium:latest # POSTGRES_PASSWORD anything, it never leaves the internal network # PROXY_SECRET shared with Caddy (`openssl rand -hex 32`): without it in the # X-Proxy-Secret header, a request is refused # APP_PORT host port for the reverse proxy to point at (default 3011) # LOGOUT_URL logout page of Authelia, e.g. https://authelia.tibiscuit.ch/logout # APP__TIMETAGGER__URL API of TimeTagger, e.g. https://tagger.tibiscuit.ch/api/v2 # # The settings of each person also come from the environment, by login (all optional): # APP__USERS____STUDENT_NAME, APP__USERS____STUDENT_ID, # APP__USERS____TIMETAGGER_TOKEN # The variables of a stack only fill the ${...} of this file, they do not reach the # container by themselves: a new person needs their lines in `app.environment`. services: db: image: postgres:18.3-alpine restart: unless-stopped environment: POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?set POSTGRES_PASSWORD in the stack} POSTGRES_DB: studium volumes: # Postgres 18 moved PGDATA to /var/lib/postgresql/18/docker and its declared # VOLUME to /var/lib/postgresql. Mounting the pre-18 /var/lib/postgresql/data # leaves the real data outside the volume, and trips the entrypoint. - db_data:/var/lib/postgresql healthcheck: test: ['CMD-SHELL', 'pg_isready -U postgres -d studium'] interval: 5s timeout: 5s retries: 10 # initdb runs on the very first boot: do not count failures before it is done start_period: 30s networks: [internal] # Runs once per deployment, before the app: applies any new migration, then exits migrate: image: ${IMAGE:?set IMAGE in the stack} restart: 'no' entrypoint: ['dbmate', '--migrations-dir', '/app/db/migrations', '--no-dump-schema', 'up'] environment: DATABASE_URL: postgres://postgres:${POSTGRES_PASSWORD}@db:5432/studium?sslmode=disable depends_on: db: condition: service_healthy networks: [internal] app: image: ${IMAGE:?set IMAGE in the stack} restart: unless-stopped ports: - '${APP_PORT:-3011}:3000' environment: APP__POSTGRES__PASSWORD: ${POSTGRES_PASSWORD} # The app trusts the Remote-User header of Authelia: only the requests carrying # this secret, added by Caddy, are accepted APP__AUTH__PROXY_SECRET: ${PROXY_SECRET:?set PROXY_SECRET in the stack} APP__AUTH__LOGOUT_URL: ${LOGOUT_URL:-} # Empty values are ignored by the app, so an unset variable keeps the default APP__TIMETAGGER__URL: ${APP__TIMETAGGER__URL:-} APP__USERS__APPELLET__STUDENT_NAME: ${APP__USERS__APPELLET__STUDENT_NAME:-} APP__USERS__APPELLET__STUDENT_ID: ${APP__USERS__APPELLET__STUDENT_ID:-} APP__USERS__APPELLET__TIMETAGGER_TOKEN: ${APP__USERS__APPELLET__TIMETAGGER_TOKEN:-} volumes: # Files of the courses: a folder per person. Must belong to uid 1000, the user # of the container. - /mnt/nas.data/dockers/studium:/data/storage depends_on: db: condition: service_healthy migrate: condition: service_completed_successfully networks: [internal] volumes: db_data: networks: internal: