Make the app port configurable (PORT) #4

Merged
reudy merged 1 commit from feat/configurable-port into main 2026-10-10 00:50:04 +02:00
5 changed files with 18 additions and 10 deletions
Showing only changes of commit 0217d62bf0 - Show all commits

View file

@ -506,7 +506,7 @@ e2e/ Playwright tests
## 13. Deployment (podman compose, with or without the panel) ## 13. Deployment (podman compose, with or without the panel)
`compose.yaml` (repo root) runs the `app` service: the Node server, which `compose.yaml` (repo root) runs the `app` service: the Node server, which
also serves the built static client, on port 8080 with its data in the also serves the built static client, on port 8080 (`PORT`) with its data in the
`oweme-data` volume. It works with **zero configuration**: VAPID keys are `oweme-data` volume. It works with **zero configuration**: VAPID keys are
generated on first start and stored in the volume (`vapid.json`, mode 600), generated on first start and stored in the volume (`vapid.json`, mode 600),
and the push contact defaults to `https://<site domain>`. and the push contact defaults to `https://<site domain>`.
@ -514,11 +514,11 @@ and the push contact defaults to `https://<site domain>`.
Every setting is an optional environment variable, written in `compose.yaml` Every setting is an optional environment variable, written in `compose.yaml`
as `${VAR:-default}` so it is visible and documented in one place: as `${VAR:-default}` so it is visible and documented in one place:
`MAX_PHOTO_BYTES`, `MAX_EVENT_BYTES`, `MAX_GROUP_BYTES`, `MAX_PHOTO_BYTES`, `MAX_EVENT_BYTES`, `MAX_GROUP_BYTES`,
`GROUP_CREATE_PER_HOUR`, `VAPID_SUBJECT`, `VAPID_PUBLIC_KEY` / `GROUP_CREATE_PER_HOUR`, `PORT`, `VAPID_SUBJECT`, `VAPID_PUBLIC_KEY` /
`VAPID_PRIVATE_KEY` (pin keys), `PUSH_DISABLED`. `VAPID_PRIVATE_KEY` (pin keys), `PUSH_DISABLED`.
- **With the panel** (the main target): the panel clones the repo, finds - **With the panel** (the main target): the panel clones the repo, finds
`compose.yaml` at the root, routes the app's domain to `app:8080` through `compose.yaml` at the root, routes the app's domain to `app:$PORT` through
its own Caddy (HTTPS) and passes the Environment tab's variables to its own Caddy (HTTPS) and passes the Environment tab's variables to
compose for `${VAR}` interpolation. "Pass to every container" must stay compose for `${VAR}` interpolation. "Pass to every container" must stay
off until the panel's injection override stops clashing with variables the off until the panel's injection override stops clashing with variables the

View file

@ -2,7 +2,8 @@
# overridden with an environment variable (in the panel's Environment tab, # overridden with an environment variable (in the panel's Environment tab,
# or in a .env file next to this file). # or in a .env file next to this file).
# #
# With the panel: point the app's domain at service `app`, port 8080. # With the panel: point the app's domain at service `app`, port $PORT
# (8080 unless you set PORT).
# The panel's Caddy provides HTTPS. # The panel's Caddy provides HTTPS.
# Standalone (no panel): set DOMAIN and run # Standalone (no panel): set DOMAIN and run
# podman compose --profile standalone up -d --build # podman compose --profile standalone up -d --build
@ -34,19 +35,21 @@ services:
VAPID_PRIVATE_KEY: ${VAPID_PRIVATE_KEY:-} VAPID_PRIVATE_KEY: ${VAPID_PRIVATE_KEY:-}
# 1 = turn push notifications off. # 1 = turn push notifications off.
PUSH_DISABLED: ${PUSH_DISABLED:-0} PUSH_DISABLED: ${PUSH_DISABLED:-0}
# Port the app listens on inside the container. If you change it,
# point the panel's domain at the new port too.
PORT: ${PORT:-8080}
# Fixed for the container; no need to change these. # Fixed for the container; no need to change these.
HOST: 0.0.0.0 HOST: 0.0.0.0
PORT: "8080"
DATA_DIR: /data DATA_DIR: /data
STATIC_DIR: /app/web STATIC_DIR: /app/web
TRUST_PROXY: "1" TRUST_PROXY: "1"
volumes: volumes:
- oweme-data:/data - oweme-data:/data
healthcheck: healthcheck:
test: ["CMD", "wget", "-qO-", "http://127.0.0.1:8080/api/health"] test: ["CMD", "wget", "-qO-", "http://127.0.0.1:${PORT:-8080}/api/health"]
interval: 30s interval: 30s
timeout: 5s timeout: 5s
# No ports: the panel publishes 8080 for its routes; standalone, only # No ports: the panel publishes $PORT for its routes; standalone, only
# Caddy reaches the app. # Caddy reaches the app.
caddy: caddy:
@ -58,6 +61,8 @@ services:
environment: environment:
# Public hostname for standalone HTTPS (needs a DNS record). # Public hostname for standalone HTTPS (needs a DNS record).
DOMAIN: ${DOMAIN:-localhost} DOMAIN: ${DOMAIN:-localhost}
# Where Caddy finds the app (same as the app's PORT).
APP_PORT: ${PORT:-8080}
ports: ports:
# Rootless Podman can't bind ports below 1024 by default; see # Rootless Podman can't bind ports below 1024 by default; see
# deploy/README.md "Ports". # deploy/README.md "Ports".

View file

@ -3,7 +3,7 @@
# Security headers (CSP etc.) are set by the app itself. # Security headers (CSP etc.) are set by the app itself.
{$DOMAIN} { {$DOMAIN} {
encode zstd gzip encode zstd gzip
reverse_proxy app:8080 { reverse_proxy app:{$APP_PORT:8080} {
# Server-Sent Events: don't buffer # Server-Sent Events: don't buffer
flush_interval -1 flush_interval -1
} }

View file

@ -25,5 +25,6 @@ COPY --from=build /src/apps/web/dist ./web
RUN mkdir -p /data && chown node:node /data RUN mkdir -p /data && chown node:node /data
USER node USER node
VOLUME /data VOLUME /data
# Default port; compose sets PORT (see compose.yaml).
EXPOSE 8080 EXPOSE 8080
CMD ["node", "--disable-warning=ExperimentalWarning", "server/main.ts"] CMD ["node", "--disable-warning=ExperimentalWarning", "server/main.ts"]

View file

@ -1,7 +1,7 @@
# Deploying OweMe # Deploying OweMe
`compose.yaml` (repo root) runs the **app** container: the Node server plus `compose.yaml` (repo root) runs the **app** container: the Node server plus
the built web client, listening on port 8080, with its data in the the built web client, listening on port 8080 (or `PORT`), with its data in the
`oweme-data` volume. It needs **no configuration**: push keys are generated `oweme-data` volume. It needs **no configuration**: push keys are generated
on first start and kept in the volume. Every setting is an optional on first start and kept in the volume. Every setting is an optional
environment variable, listed with its default in `compose.yaml`. environment variable, listed with its default in `compose.yaml`.
@ -13,7 +13,8 @@ container enabled with the `standalone` profile.
1. **New app → Git repository**: this repo, branch `main`. The panel finds 1. **New app → Git repository**: this repo, branch `main`. The panel finds
`compose.yaml` in the repository root. `compose.yaml` in the repository root.
2. **Domain**: point it at service **`app`**, port **`8080`**. The panel 2. **Domain**: point it at service **`app`**, port **`8080`** (or the
`PORT` you set in the Environment tab). The panel
publishes the port on 127.0.0.1 and its Caddy serves HTTPS. publishes the port on 127.0.0.1 and its Caddy serves HTTPS.
3. **Environment** (optional): any variable from `compose.yaml`, for example 3. **Environment** (optional): any variable from `compose.yaml`, for example
`MAX_PHOTO_BYTES=5242880` or `VAPID_SUBJECT=mailto:you@example.com`. `MAX_PHOTO_BYTES=5242880` or `VAPID_SUBJECT=mailto:you@example.com`.
@ -72,6 +73,7 @@ standalone deploy.
| `VAPID_SUBJECT` | `https://<site domain>` | Contact sent to push services | | `VAPID_SUBJECT` | `https://<site domain>` | Contact sent to push services |
| `VAPID_PUBLIC_KEY` / `VAPID_PRIVATE_KEY` | generated | Pin push keys (set both); otherwise kept in the volume as `vapid.json` | | `VAPID_PUBLIC_KEY` / `VAPID_PRIVATE_KEY` | generated | Pin push keys (set both); otherwise kept in the volume as `vapid.json` |
| `PUSH_DISABLED` | `0` | `1` turns push notifications off | | `PUSH_DISABLED` | `0` | `1` turns push notifications off |
| `PORT` | `8080` | Port the app listens on inside the container (the panel's domain must target it) |
| `DOMAIN` | `localhost` | Standalone only: Caddy's site address and certificate | | `DOMAIN` | `localhost` | Standalone only: Caddy's site address and certificate |
| `BIND_ADDR` | `0.0.0.0` | Standalone only: address Caddy's ports are published on | | `BIND_ADDR` | `0.0.0.0` | Standalone only: address Caddy's ports are published on |
| `HTTP_PORT` / `HTTPS_PORT` | `80` / `443` | Standalone only: host ports for Caddy | | `HTTP_PORT` / `HTTPS_PORT` | `80` / `443` | Standalone only: host ports for Caddy |