This commit is contained in:
Michael committed 2026-08-06 19:04:06 +12:00
1 parent acb5070622
commit 07d2595678
3 files changed
+78 -33

No files matched your search

+27 -14
View File
@@ -47,12 +47,15 @@ the full list and a description of each. The two driver toggles:
- **`DB_DRIVER`**: `postgres` (default) or `sqlite`. With `sqlite`, - **`DB_DRIVER`**: `postgres` (default) or `sqlite`. With `sqlite`,
`DATABASE_URL` is a file path (e.g. `./data/vlog.db`) instead of a DSN, and `DATABASE_URL` is a file path (e.g. `./data/vlog.db`) instead of a DSN, and
the schema is applied idempotently on startup — no golang-migrate, no the schema is applied idempotently on startup — no golang-migrate, no
external DB needed. Meant for local dev/testing; use Postgres in external DB needed. Good for local dev/testing, and just as fine for a
production. real single-server/personal-use deployment (see `deploy/docker-compose.yml`)
— use Postgres only if you actually need a separate DB server.
- **`STORAGE_DRIVER`**: `s3` (default) or `local`. With `local`, uploads are - **`STORAGE_DRIVER`**: `s3` (default) or `local`. With `local`, uploads are
written under `LOCAL_STORAGE_PATH` (default `./data/uploads`) instead of written under `LOCAL_STORAGE_PATH` (default `./data/uploads`) instead of
S3 — no AWS credentials needed. Meant for local dev/testing; use S3 in S3 — no AWS credentials needed. Same story: fine for production too as
production. long as the volume backing `LOCAL_STORAGE_PATH` is actually durable (i.e.
a real disk/volume, not ephemeral container storage) — use S3 if you want
uploads off-box.
Everything else (`OIDC_*`, `PUBLIC_BASE_URL`, `JWT_SIGNING_SECRET`) is Everything else (`OIDC_*`, `PUBLIC_BASE_URL`, `JWT_SIGNING_SECRET`) is
required regardless — there's no toggle for OIDC, you'll need a real (or required regardless — there's no toggle for OIDC, you'll need a real (or
@@ -80,31 +83,41 @@ dev server side by side.
## Deploying ## Deploying
`deploy/docker-compose.yml` is wired for `DB_DRIVER=sqlite` +
`STORAGE_DRIVER=local` out of the box — config as literal env values right
in the file (no separate `.env`), matching the convention used for other
services on the host: one folder per service, `./data` bind-mounted in,
published on a `127.0.0.1` port for the host's own Caddy to reverse-proxy
to. Fill in the `OIDC_*`/`PUBLIC_BASE_URL`/`JWT_SIGNING_SECRET` placeholders
(still required either way — there's no toggle for OIDC), then:
```sh ```sh
cd deploy cd deploy
cp .env.example .env # fill in real values (DB_DRIVER=postgres, STORAGE_DRIVER=s3)
docker compose up -d --build docker compose up -d --build
``` ```
This starts one container: `app` (the Go binary, built via This starts one container: `vlog` (the Go binary, built via
`backend/Dockerfile`, which builds the frontend and embeds it in the same `backend/Dockerfile`, which builds the frontend and embeds it in the same
multi-stage build), published on `PORT` (default `8080`). Postgres, the multi-stage build), published on `127.0.0.1:4012` (pick any free port —
OIDC provider, and TLS termination are all assumed to already exist — that's what your Caddy config points at). The OIDC provider and TLS
nothing else runs in this compose file. termination are assumed to already exist — nothing else runs in this
compose file.
Point your existing Caddy config at it: Point your existing Caddy config at it:
``` ```
garage.example.com { garage.example.com {
reverse_proxy localhost:8080 reverse_proxy localhost:4012
} }
``` ```
(Use the app container's name instead of `localhost` if your Caddy also To use Postgres + S3 instead, swap the relevant env values for the ones in
runs in Docker on the same network.) `deploy/.env.example` (a full reference list of every var the app reads).
The schema applies automatically on every `app` startup — there's no The schema applies automatically on every startup — there's no separate
separate migrate step to remember. migrate step to remember, and for SQLite specifically, adding a new column
to an existing local DB file is also handled automatically (no need to
delete and recreate it as the schema evolves).
## Verification checklist ## Verification checklist
+5 -1
View File
@@ -1,4 +1,8 @@
# Copy to deploy/.env and fill in — docker compose loads this automatically. # Reference list of every env var the app reads — see docker-compose.yml for
# how they're actually wired in (literal values right in that file, matching
# this host's convention for other services, not a separate .env). Copy
# values from here into the `environment:` block there, or into a `.env`
# yourself if you'd rather use `${VAR}` substitution in the compose file.
# --- Database --- # --- Database ---
# "postgres" (production, default) or "sqlite" (local dev/testing, no # "postgres" (production, default) or "sqlite" (local dev/testing, no
+46 -18
View File
@@ -1,26 +1,54 @@
# Matches the house style used for other services on this host (gittea,
# etc.): one folder per service, config as literal env values right in this
# file (no separate .env), bind-mounted ./data, published on a 127.0.0.1
# port for the host's own Caddy to reverse_proxy to.
#
# This example is wired for DB_DRIVER=sqlite + STORAGE_DRIVER=local — no
# Postgres or S3 needed, everything lives under ./data. Fine for production
# on a single-server/personal-use deployment like this one; swap to
# postgres/s3 by changing the env values below (see deploy/.env.example for
# the full var list either way).
services: services:
app: vlog:
build: build:
context: .. context: ..
dockerfile: backend/Dockerfile dockerfile: backend/Dockerfile
container_name: vlog
restart: unless-stopped restart: unless-stopped
# Only needed if your OIDC provider runs on the host itself (or another
# compose stack not on this network) rather than a public domain — same
# reason gittea reaches Postgres via host.docker.internal. Safe to leave
# in even if unused.
extra_hosts:
- "host.docker.internal:host-gateway"
# Pick any free host port — this is what your Caddy config points at.
ports: ports:
- "${PORT:-8080}:8080" - "127.0.0.1:4012:8080"
environment:
DB_DRIVER: ${DB_DRIVER:-postgres}
DATABASE_URL: ${DATABASE_URL}
PORT: "8080"
OIDC_ISSUER_URL: ${OIDC_ISSUER_URL}
OIDC_CLIENT_ID: ${OIDC_CLIENT_ID}
OIDC_CLIENT_SECRET: ${OIDC_CLIENT_SECRET}
OIDC_REDIRECT_URL: ${OIDC_REDIRECT_URL}
PUBLIC_BASE_URL: ${PUBLIC_BASE_URL}
JWT_SIGNING_SECRET: ${JWT_SIGNING_SECRET}
STORAGE_DRIVER: ${STORAGE_DRIVER:-s3}
LOCAL_STORAGE_PATH: ${LOCAL_STORAGE_PATH:-./data/uploads}
AWS_REGION: ${AWS_REGION}
AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID}
AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY}
S3_BUCKET_NAME: ${S3_BUCKET_NAME}
volumes: volumes:
- ./data:/data - ./data:/data
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
environment:
- DB_DRIVER=sqlite
- DATABASE_URL=/data/vlog.db
- PORT=8080
- STORAGE_DRIVER=local
- LOCAL_STORAGE_PATH=/data/uploads
# Point at your existing OIDC provider (Authentik/Keycloak/Zitadel/etc).
# Register OIDC_REDIRECT_URL with it as this app's callback URL.
- OIDC_ISSUER_URL=https://auth.example.com/realms/your-realm
- OIDC_CLIENT_ID=vlog
- OIDC_CLIENT_SECRET=changeme
- OIDC_REDIRECT_URL=https://garage.example.com/api/auth/callback
# Whatever your Caddy config serves this app as — controls whether
# session cookies are marked Secure (only over https://).
- PUBLIC_BASE_URL=https://garage.example.com
# openssl rand -base64 32
- JWT_SIGNING_SECRET=changeme