Skip to content
All guides: Compose file and settings template

Compose file and settings template

These files run a self-hosted Peppy server and are shown as published in the public repository. Follow the install steps in Install the Community server.

On this page#

docker-compose.yml#

Save this Compose file in your server folder.

# Copy beside a .env and run Docker Compose v2.24+: only five values are required. Developers add infra/compose/compose.build.yml.
name: peppy

services:
  database-password-preflight:
    image: postgres:18.1@sha256:1090bc3a8ccfb0b55f78a494d76f8d603434f7e4553543d6e807bc7bd6bbd17f
    entrypoint: ["/bin/sh", "/usr/local/bin/validate-db-passwords.sh"]
    environment:
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?set in .env}
      PEPPY_RUNTIME_DB_PASSWORD: ${PEPPY_RUNTIME_DB_PASSWORD:?set in .env}
      PEPPY_MAINTENANCE_DB_PASSWORD: ${PEPPY_MAINTENANCE_DB_PASSWORD:?set in .env}
    configs:
      - source: database-password-preflight
        target: /usr/local/bin/validate-db-passwords.sh
    tmpfs:
      - /var/lib/postgresql
    restart: "no"

  postgres:
    image: postgres:18.1@sha256:1090bc3a8ccfb0b55f78a494d76f8d603434f7e4553543d6e807bc7bd6bbd17f
    environment:
      POSTGRES_DB: ${POSTGRES_DB:-peppy}
      POSTGRES_USER: ${POSTGRES_USER:-peppy}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?set in .env}
      PEPPY_RUNTIME_DB_USER: ${PEPPY_RUNTIME_DB_USER:-peppy_runtime}
      PEPPY_RUNTIME_DB_PASSWORD: ${PEPPY_RUNTIME_DB_PASSWORD:?set in .env}
      PEPPY_MAINTENANCE_DB_USER: ${PEPPY_MAINTENANCE_DB_USER:-peppy_maintenance}
      PEPPY_MAINTENANCE_DB_PASSWORD: ${PEPPY_MAINTENANCE_DB_PASSWORD:?set in .env}
    configs:
      - source: database-password-preflight
        target: /usr/local/bin/validate-db-passwords.sh
      - source: bootstrap-roles
        target: /usr/local/bin/peppy-bootstrap-roles.sh
      - source: bootstrap-roles-init
        target: /docker-entrypoint-initdb.d/10-peppy-roles.sh
    volumes:
      - postgres-data:/var/lib/postgresql
    depends_on:
      database-password-preflight:
        condition: service_completed_successfully
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB"]
      interval: 5s
      timeout: 3s
      retries: 20
      start_period: 5s
    networks: [private]
    restart: unless-stopped

  seaweedfs:
    image: chrislusf/seaweedfs:4.48@sha256:4e61d15fd35994cb1e43e1e553dff106794841fd9a99ade2fc8c8bfce4d7872d
    entrypoint: ["/bin/sh", "/usr/local/bin/peppy-seaweedfs-entrypoint.sh"]
    command: >-
      server -s3 -s3.port=8333 -s3.config=/etc/seaweedfs/s3.json -dir=/data -master.port=9333 -volume.port=8080
      -filer -filer.port=8888 -filer.encryptVolumeData -ip=seaweedfs -ip.bind=0.0.0.0
    configs:
      - source: seaweed-s3-config
        target: /etc/seaweedfs/s3.json
      - source: seaweed-entrypoint
        target: /usr/local/bin/peppy-seaweedfs-entrypoint.sh
    volumes:
      - seaweed-volume-data:/data
      - seaweed-filer-data:/root/.seaweedfs
    healthcheck:
      test: ["CMD-SHELL", "wget -S -O /dev/null http://127.0.0.1:8333/ 2>&1 | grep -Eq 'HTTP/.* (401|403)'"]
      interval: 5s
      timeout: 3s
      retries: 20
      start_period: 5s
    networks: [private]
    restart: unless-stopped

  migrate:
    image: ${PEPPY_SERVER_IMAGE:-hub.docker.visnovsky.us/library/peppy-server:latest}
    command: ["migrate"]
    environment:
      DATABASE_URL: postgres://${PEPPY_RUNTIME_DB_USER:-peppy_runtime}:${PEPPY_RUNTIME_DB_PASSWORD:?set in .env}@postgres:5432/${POSTGRES_DB:-peppy}
      DATABASE_MIGRATION_URL: postgres://${POSTGRES_USER:-peppy}:${POSTGRES_PASSWORD:?set in .env}@postgres:5432/${POSTGRES_DB:-peppy}
      MAINTENANCE_DATABASE_URL: postgres://${PEPPY_MAINTENANCE_DB_USER:-peppy_maintenance}:${PEPPY_MAINTENANCE_DB_PASSWORD:?set in .env}@postgres:5432/${POSTGRES_DB:-peppy}
    depends_on:
      database-password-preflight:
        condition: service_completed_successfully
      postgres:
        condition: service_healthy
    networks: [private]
    restart: "no"

  api:
    image: ${PEPPY_SERVER_IMAGE:-hub.docker.visnovsky.us/library/peppy-server:latest}
    environment:
      PEPPY_ENV: ${PEPPY_ENV:-production}
      PUBLIC_API_URL: ${PUBLIC_API_URL:-https://${PUBLIC_HOST:-}}
      DATABASE_URL: postgres://${PEPPY_RUNTIME_DB_USER:-peppy_runtime}:${PEPPY_RUNTIME_DB_PASSWORD:?set in .env}@postgres:5432/${POSTGRES_DB:-peppy}
      MAINTENANCE_DATABASE_URL: postgres://${PEPPY_MAINTENANCE_DB_USER:-peppy_maintenance}:${PEPPY_MAINTENANCE_DB_PASSWORD:?set in .env}@postgres:5432/${POSTGRES_DB:-peppy}
      S3_INTERNAL_ENDPOINT: http://seaweedfs:8333
      S3_ACCESS_KEY: ${S3_ACCESS_KEY:-peppy}
      S3_SECRET_KEY: ${S3_SECRET_KEY:?set in .env}
      S3_BUCKET: ${S3_BUCKET:-peppy-private}
      # Unset keeps the server default.
      PEPPY_REPLAY_RETENTION_DAYS:
      VAULT_ATTACHMENT_QUOTA_BYTES:
      PEPPY_WEB_CLIENT_ROOT: ${WEB_UI_ENABLED:-true}
      PEPPY_WEB_CLIENT_ACCOUNT_URL: ${WEB_CLIENT_ACCOUNT_URL:-}
      PEPPY_SETUP_TOKEN: ${PEPPY_SETUP_TOKEN:-}
      TRUSTED_PROXY_CIDRS: ${TRUSTED_PROXY_CIDRS:-}
    depends_on:
      database-password-preflight:
        condition: service_completed_successfully
      postgres:
        condition: service_healthy
      seaweedfs:
        condition: service_healthy
      migrate:
        condition: service_completed_successfully
    ports:
      - "${API_BIND_IP:-127.0.0.1}:${API_HOST_PORT:-7000}:8080"
    read_only: true
    tmpfs:
      - /tmp
    cap_drop: [ALL]
    security_opt:
      - no-new-privileges:true
    healthcheck:
      test: ["CMD", "/usr/local/bin/peppy-server", "healthcheck"]
      interval: 5s
      timeout: 3s
      retries: 20
      start_period: 5s
    networks: [private, edge]
    restart: unless-stopped

networks:
  private:
    internal: true
  edge:

volumes:
  postgres-data:
  seaweed-volume-data:
  seaweed-filer-data:

configs:
  database-password-preflight:
    # Literal dollars are escaped because Compose interpolates config content.
    content: |
      #!/bin/sh
      set -eu

      validate_password() {
        case "$$1" in
          ''|*[!A-Za-z0-9._~-]*)
            echo "database passwords must use only URI-unreserved characters: A-Z a-z 0-9 . _ ~ -" >&2
            exit 1
            ;;
        esac
      }

      : "$${POSTGRES_PASSWORD:?POSTGRES_PASSWORD is required}"
      : "$${PEPPY_RUNTIME_DB_PASSWORD:?PEPPY_RUNTIME_DB_PASSWORD is required}"
      : "$${PEPPY_MAINTENANCE_DB_PASSWORD:?PEPPY_MAINTENANCE_DB_PASSWORD is required}"

      for password in "$$POSTGRES_PASSWORD" "$$PEPPY_RUNTIME_DB_PASSWORD" "$$PEPPY_MAINTENANCE_DB_PASSWORD"; do
        validate_password "$$password"
      done
  bootstrap-roles:
    content: |
      #!/bin/sh
      set -eu

      : "$${PEPPY_RUNTIME_DB_USER:?PEPPY_RUNTIME_DB_USER is required}"
      : "$${PEPPY_RUNTIME_DB_PASSWORD:?PEPPY_RUNTIME_DB_PASSWORD is required}"
      : "$${PEPPY_MAINTENANCE_DB_USER:?PEPPY_MAINTENANCE_DB_USER is required}"
      : "$${PEPPY_MAINTENANCE_DB_PASSWORD:?PEPPY_MAINTENANCE_DB_PASSWORD is required}"

      sh /usr/local/bin/validate-db-passwords.sh

      if [ "$$PEPPY_RUNTIME_DB_USER" = "$$POSTGRES_USER" ] || [ "$$PEPPY_MAINTENANCE_DB_USER" = "$$POSTGRES_USER" ] || [ "$$PEPPY_RUNTIME_DB_USER" = "$$PEPPY_MAINTENANCE_DB_USER" ]; then
        echo "database runtime and maintenance roles must be distinct from the owner and each other" >&2
        exit 1
      fi

      psql --set=ON_ERROR_STOP=1 --username "$$POSTGRES_USER" --dbname "$$POSTGRES_DB" \
        --set=runtime_role="$$PEPPY_RUNTIME_DB_USER" \
        --set=runtime_password="$$PEPPY_RUNTIME_DB_PASSWORD" \
        --set=maintenance_role="$$PEPPY_MAINTENANCE_DB_USER" \
        --set=maintenance_password="$$PEPPY_MAINTENANCE_DB_PASSWORD" <<'SQL'
      SELECT format('CREATE ROLE %I LOGIN NOSUPERUSER NOCREATEDB NOCREATEROLE NOINHERIT NOBYPASSRLS PASSWORD %L', :'runtime_role', :'runtime_password')
      WHERE NOT EXISTS (SELECT FROM pg_roles WHERE rolname = :'runtime_role')
      \gexec
      SELECT format('ALTER ROLE %I LOGIN NOSUPERUSER NOCREATEDB NOCREATEROLE NOINHERIT NOBYPASSRLS PASSWORD %L', :'runtime_role', :'runtime_password')
      \gexec
      SELECT format('CREATE ROLE %I LOGIN NOSUPERUSER NOCREATEDB NOCREATEROLE NOINHERIT BYPASSRLS PASSWORD %L', :'maintenance_role', :'maintenance_password')
      WHERE NOT EXISTS (SELECT FROM pg_roles WHERE rolname = :'maintenance_role')
      \gexec
      SELECT format('ALTER ROLE %I LOGIN NOSUPERUSER NOCREATEDB NOCREATEROLE NOINHERIT BYPASSRLS PASSWORD %L', :'maintenance_role', :'maintenance_password')
      \gexec
      SQL
  bootstrap-roles-init:
    content: |
      sh /usr/local/bin/peppy-bootstrap-roles.sh
  seaweed-entrypoint:
    content: |
      #!/bin/sh
      set -eu

      state_dir=/root/.seaweedfs
      data_dir=/data
      key_path=$$state_dir/.peppy-s3-sse-kek

      fail() {
        echo "SeaweedFS KEK bootstrap failed: $$1" >&2
        exit 1
      }

      # SeaweedFS accepts this variable internally. Clear any supplied encryption
      # variables so the persisted machine key is the only possible source.
      for variable in $$(env | sed -n 's/^\(WEED_[A-Za-z0-9_]*\)=.*/\1/p'); do
        case "$$variable" in
          *SSE*|*KEK*|*ENCRYPT*) unset "$$variable" ;;
        esac
      done

      if [ -L "$$state_dir" ]; then
        fail 'state directory is a symlink'
      fi
      if [ ! -e "$$state_dir" ]; then
        umask 077
        mkdir "$$state_dir" || fail 'cannot create state directory'
      fi
      if [ ! -d "$$state_dir" ]; then
        fail 'state path is not a directory'
      fi
      if [ ! -r "$$state_dir" ] || [ ! -x "$$state_dir" ]; then
        fail 'state directory is unreadable'
      fi
      if [ -L "$$key_path" ]; then
        fail 'stored key is a symlink'
      fi

      validate_stored_key() {
        [ "$$(wc -c <"$$key_path" | tr -d ' ')" = 64 ] || return 1
        key=$$(cat "$$key_path") || return 1
        [ "$${#key}" = 64 ] || return 1
        case "$$key" in
          *[!0-9a-f]*) return 1 ;;
        esac
        [ "$$(stat -c %a "$$key_path")" = 600 ] || return 1
      }

      has_initialized_filer_state() {
        entries=$$(find "$$1" -mindepth 1 -maxdepth 1 -print -quit) || fail 'cannot enumerate state directory'
        [ -n "$$entries" ]
      }

      has_initialized_data_state() {
        [ -e "$$data_dir" ] || return 1
        [ -d "$$data_dir" ] || return 0
        [ -r "$$data_dir" ] && [ -x "$$data_dir" ] || fail 'data directory is unreadable'

        for entry in "$$data_dir"/* "$$data_dir"/.[!.]* "$$data_dir"/..?*; do
          [ -e "$$entry" ] || [ -L "$$entry" ] || continue
          if [ "$$entry" = "$$data_dir/filerldb2" ] && [ -d "$$entry" ] && [ ! -L "$$entry" ]; then
            [ -r "$$entry" ] && [ -x "$$entry" ] || fail 'filer metadata directory is unreadable'
            entries=$$(find "$$entry" -mindepth 1 -print -quit) || fail 'cannot enumerate filer metadata directory'
            [ -n "$$entries" ] && return 0
          else
            return 0
          fi
        done
        return 1
      }

      if [ -e "$$key_path" ]; then
        validate_stored_key || fail 'stored key is malformed or insecure'
      else
        for stale_key in "$$state_dir"/.peppy-s3-sse-kek.*; do
          [ -e "$$stale_key" ] || continue
          [ ! -L "$$stale_key" ] && [ -f "$$stale_key" ] || fail 'temporary key state is unsafe'
          rm -f "$$stale_key" || fail 'cannot remove incomplete temporary key'
        done
        sync -f "$$state_dir" || fail 'cannot sync state directory'
        if has_initialized_filer_state "$$state_dir" || has_initialized_data_state; then
          fail 'stored key is missing from initialized state'
        fi

        umask 077
        temporary_key=$$(mktemp "$$state_dir/.peppy-s3-sse-kek.XXXXXX") || fail 'cannot create temporary key'
        key=$$(od -An -N32 -tx1 /dev/urandom | tr -d ' \n') || fail 'cannot generate stored key'
        [ "$${#key}" = 64 ] || fail 'generated key is malformed'
        case "$$key" in
          *[!0-9a-f]*) fail 'generated key is malformed' ;;
        esac
        printf '%s' "$$key" >"$$temporary_key" || fail 'cannot write stored key'
        chmod 600 "$$temporary_key" || fail 'cannot secure stored key permissions'
        sync -f "$$temporary_key" || fail 'cannot sync temporary key'
        if ! mv -n "$$temporary_key" "$$key_path"; then
          rm -f "$$temporary_key"
          fail 'cannot atomically install stored key'
        fi
        if [ -e "$$temporary_key" ]; then
          rm -f "$$temporary_key"
        fi
        if [ -L "$$key_path" ] || ! validate_stored_key; then
          fail 'stored key is malformed or insecure'
        fi
        sync -f "$$key_path" || fail 'cannot sync stored key'
        sync -f "$$state_dir" || fail 'cannot sync state directory'
      fi

      export WEED_S3_SSE_KEK="$$key"
      exec /entrypoint.sh "$$@"
  seaweed-s3-config:
    content: |
      {"identities":[{"name":"peppy-private","credentials":[{"accessKey":"${S3_ACCESS_KEY:-peppy}","secretKey":"${S3_SECRET_KEY}"}],"actions":["Read","Write","List","Tagging","Admin"]}]}

.env.example#

Save this as .env beside the Compose file and set the five required values; see Server settings for what each setting does.

# Copy this file beside docker-compose.yml as .env. Never commit .env.

# Required
PUBLIC_HOST=peppy.example.com
# Use one password per database role. Generate each with `openssl rand -hex 24`;
# values must use only A-Z a-z 0-9 . _ ~ -.
POSTGRES_PASSWORD=
PEPPY_RUNTIME_DB_PASSWORD=
PEPPY_MAINTENANCE_DB_PASSWORD=
S3_SECRET_KEY=

# Recommended
# A nonempty setup token must be at least 32 UTF-8 bytes. Empty lets the first
# device to finish setup claim the server; use the same value on every replica.
# PEPPY_SETUP_TOKEN=

# Optional
# Pin a version such as :0.43.0 or a digest; defaults to :latest.
# PEPPY_SERVER_IMAGE=hub.docker.visnovsky.us/library/peppy-server:0.43.0
# PEPPY_MCP_IMAGE=hub.docker.visnovsky.us/library/peppy-mcp:0.43.0
# Defaults to https://PUBLIC_HOST.
# PUBLIC_API_URL=https://peppy.example.com
# Direct reverse-proxy peers allowed to supply forwarded client addresses.
# TRUSTED_PROXY_CIDRS=192.0.2.10/32,2001:db8::10/128
# API_BIND_IP=127.0.0.1
# API_HOST_PORT=7000
# WEB_UI_ENABLED=true
# WEB_CLIENT_ACCOUNT_URL=
# MAX_UPLOAD_BYTES=64MB
# VAULT_ATTACHMENT_QUOTA_BYTES=536870912
# PEPPY_REPLAY_RETENTION_DAYS=30

# Advanced: only change before first start.
# POSTGRES_DB=peppy
# POSTGRES_USER=peppy
# PEPPY_RUNTIME_DB_USER=peppy_runtime
# PEPPY_MAINTENANCE_DB_USER=peppy_maintenance
# S3_ACCESS_KEY=peppy
# S3_BUCKET=peppy-private
# PEPPY_ENV=production

HTTPS overlay#

For HTTPS, save this as compose.caddy.yml beside the other two files, then follow Put your server online with HTTPS.

# Compose v2.24+ overlay: reverse proxy and HTTPS termination.
services:
  caddy:
    image: caddy:2.10.2-alpine@sha256:4c6e91c6ed0e2fa03efd5b44747b625fec79bc9cd06ac5235a779726618e530d
    depends_on:
      api:
        condition: service_healthy
    environment:
      PUBLIC_HOST: ${PUBLIC_HOST:?set the externally reachable HTTPS hostname}
      MAX_UPLOAD_BYTES: ${MAX_UPLOAD_BYTES:-64MB}
    configs:
      - source: caddyfile-template
        target: /etc/caddy/Caddyfile.template
      - source: caddy-entrypoint
        target: /usr/local/bin/peppy-caddy
    volumes:
      - caddy-data:/data
      - caddy-config:/config
    entrypoint: ["/bin/sh", "/usr/local/bin/peppy-caddy"]
    ports:
      - "80:80"
      - "443:443"
    cap_drop: [ALL]
    cap_add: [NET_BIND_SERVICE]
    security_opt:
      - no-new-privileges:true
    networks: [private, edge]

networks:
  edge:

volumes:
  caddy-data:
  caddy-config:

configs:
  caddyfile-template:
    # Literal dollars are escaped because Compose interpolates config content.
    content: |
      __PEPPY_HOSTS__ {
        header Strict-Transport-Security "max-age=15552000"

        request_body {
          max_size {$$MAX_UPLOAD_BYTES:64MB}
        }

        reverse_proxy api:8080 {
          header_up Host {http.request.host}
          header_up X-Forwarded-Proto https
          transport http {
            dial_timeout 5s
            response_header_timeout 30s
          }
          stream_timeout 24h
        }
      }
  caddy-entrypoint:
    content: |
      #!/bin/sh
      set -eu

      fail() {
          printf 'peppy-caddy: %s\n' "$$*" >&2
          exit 1
      }

      validate_host() {
          case "$$1" in
              ''|*[!A-Za-z0-9.-]*|.*|*..*|*.) fail "invalid hostname: $$1" ;;
          esac
      }

      : "$${PUBLIC_HOST:?set PUBLIC_HOST}"
      validate_host "$$PUBLIC_HOST"

      config=$$(mktemp)
      trap 'rm -f "$$config"' EXIT
      sed "s|__PEPPY_HOSTS__|$$PUBLIC_HOST|" /etc/caddy/Caddyfile.template >"$$config"
      if [ "$${1:-}" = validate ]; then
          exec caddy validate --config "$$config" --adapter caddyfile
      fi
      exec caddy run --config "$$config" --adapter caddyfile

Good to know#

  • The Compose file requires Docker Compose v2.24 or later.
  • The Compose file needs only .env, not the rest of the repository.
  • Backups, restores, and the MCP worker use files from a repository checkout; see Back up and restore.
  • You can also view docker-compose.yml and .env.example on GitHub.