# The service block, for the compose file that already runs your proxy. # # It needs to be on the same Docker network as SWAG, because that is how nginx # reaches it — by container name, on the network Compose gives every project. # Being in the same file is what puts it there; nothing else about it is # related to the other services, and nothing else needs to be. # # Paste this `app:` block into that file's `services:`, add the variables from # `env.example` to the `.env` next to it, and it is `docker compose up -d app` # from then on — which recreates this container and no other. # # Rename `app` and `APP_` throughout to your service's name. services: app: image: ${APP_IMAGE:?set APP_IMAGE in .env}:${APP_TAG:-latest} container_name: app restart: unless-stopped # A plain directory on the host rather than a managed volume, so a backup # is `tar` and it is owned by you rather than by root. Relative to this # file by default; set APP_DATA to an absolute path to keep every # container's data under one root, which is the thing a backup wants. volumes: - ${APP_DATA:-./data}:/data # The container follows the host directory's uid instead of the other way # round — the same PUID/PGID the rest of the stack already runs with. user: "${PUID:-1000}:${PGID:-1000}" environment: TZ: ${TZ:-Europe/Berlin} # Which model answers, decided here rather than in the image. With # `backend: auto` the API key wins when there is one and the # subscription CLI is the fallback, so filling in ANTHROPIC_API_KEY # later switches it over with no rebuild. See docs/llm-backends.md. CLAUDE_CODE_OAUTH_TOKEN: ${CLAUDE_CODE_OAUTH_TOKEN:-} ANTHROPIC_API_KEY: ${ANTHROPIC_API_KEY:-} # Normally empty. Set it to pin the password — the way back in when a # login is lost — then unset it and recreate to hand control of the # password back to the app. See docs/password-protection.md. APP_PASSWORD: ${APP_PASSWORD:-} # No `ports:`. Nothing on the host reaches it; SWAG does, by container # name, on the project's network. That is what keeps the app's port off # the internet even if the firewall is wrong. # `deploy: resources: limits:` is Swarm-only and silently ignored by # `docker compose up`. This is the one that works. 0 is unlimited, which # is the honest default until the box has been watched under real load. mem_limit: ${APP_MEM:-0} # The log is the record — nothing here writes a second copy of what went # wrong — so it is worth keeping a few rotations of, and worth capping on # a small disk. logging: driver: json-file options: max-size: "20m" max-file: "5"