feat(project): add Docker Compose with flexible storage and DB modes
Bundle the app + Postgres into a compose stack on top of the existing image.
- app: builds the image, publishes ${APP_PORT:-42776}, reads .env, pins
STATIC_DIR so SPA serving can't be disabled by an empty value
- db: postgres:14-alpine under the "with-db" profile; toggle it off via
COMPOSE_PROFILES to point the app at a Postgres on the host instead
(host.docker.internal), with depends_on required:false so it stays optional
Storage and the DB data dir each default to a named volume but can be bind
mounted to a host folder via FILES_DIR / THUMBS_DIR / IMPORT_DIR / DB_DIR.
Add PUID/PGID (via user:) so bind-mounted folders are writable by the
non-root container.
Run the container as a dedicated non-root user "tanabata" with uid/gid 42776,
reusing the project's signature number (also the default port). Document every
variable in .env.example.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+62
-9
@@ -1,8 +1,46 @@
|
||||
# =============================================================================
|
||||
# Tanabata File Manager — environment variables
|
||||
# Copy to .env and fill in the values.
|
||||
#
|
||||
# Copy to .env and fill in the secrets:
|
||||
# cp .env.example .env
|
||||
# docker compose up -d --build
|
||||
# =============================================================================
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Docker Compose (read by the compose CLI, ignored by the app)
|
||||
# ---------------------------------------------------------------------------
|
||||
# Profiles to enable. "with-db" runs the bundled Postgres container. Leave
|
||||
# EMPTY to skip it and use a Postgres running on the host instead — then point
|
||||
# DATABASE_URL at host.docker.internal (see the Database section below).
|
||||
COMPOSE_PROFILES=with-db
|
||||
|
||||
# Host port the app is published on. The container always listens on 42776.
|
||||
APP_PORT=42776
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Volume mounts (Docker Compose; ignored by the app)
|
||||
# ---------------------------------------------------------------------------
|
||||
# By default the app's data and the database live in named Docker volumes
|
||||
# (app_files, app_thumbs, app_import, db_data). To keep them in specific folders
|
||||
# on the host instead, point any of these at a host path — absolute, or relative
|
||||
# to this file (e.g. ./data/files). Unset = named volume.
|
||||
# FILES_DIR=/var/lib/tanabata/files
|
||||
# THUMBS_DIR=/var/lib/tanabata/thumbs
|
||||
# IMPORT_DIR=/var/lib/tanabata/import
|
||||
# DB_DIR=/var/lib/tanabata/db
|
||||
|
||||
# When bind-mounting the app folders above, the container must be able to write
|
||||
# to them. Set PUID/PGID to the owner of those folders and create them with
|
||||
# matching ownership first, e.g.:
|
||||
# sudo mkdir -p /var/lib/tanabata/{files,thumbs,import}
|
||||
# sudo chown -R 1000:1000 /var/lib/tanabata
|
||||
# PUID=1000
|
||||
# PGID=1000
|
||||
# Defaults match the image's tanabata user (42776), which owns the named volumes. The
|
||||
# DB folder is handled by Postgres itself and needs no PUID/PGID.
|
||||
# PUID=42776
|
||||
# PGID=42776
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Server
|
||||
# ---------------------------------------------------------------------------
|
||||
@@ -21,10 +59,25 @@ ADMIN_PASSWORD=change-me-before-first-run
|
||||
# ---------------------------------------------------------------------------
|
||||
# Database
|
||||
# ---------------------------------------------------------------------------
|
||||
DATABASE_URL=postgres://tanabata:password@localhost:5432/tanabata?sslmode=disable
|
||||
# Credentials for the bundled Postgres container (the "with-db" profile).
|
||||
# Keep these in sync with DATABASE_URL below.
|
||||
POSTGRES_DB=tanabata
|
||||
POSTGRES_USER=tanabata
|
||||
POSTGRES_PASSWORD=password
|
||||
|
||||
# Connection string the app uses. Pick ONE to match your database mode:
|
||||
#
|
||||
# • Bundled container DB (COMPOSE_PROFILES=with-db) — host is the "db" service:
|
||||
DATABASE_URL=postgres://tanabata:password@db:5432/tanabata?sslmode=disable
|
||||
#
|
||||
# • Postgres on the host (COMPOSE_PROFILES empty):
|
||||
# DATABASE_URL=postgres://tanabata:password@host.docker.internal:5432/tanabata?sslmode=disable
|
||||
#
|
||||
# • Bare-metal `go run` (no Docker):
|
||||
# DATABASE_URL=postgres://tanabata:password@localhost:5432/tanabata?sslmode=disable
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Storage
|
||||
# Storage (paths inside the container; backed by named volumes in compose)
|
||||
# ---------------------------------------------------------------------------
|
||||
FILES_PATH=/data/files
|
||||
THUMBS_CACHE_PATH=/data/thumbs
|
||||
@@ -48,9 +101,9 @@ IMPORT_PATH=/data/import
|
||||
# ---------------------------------------------------------------------------
|
||||
# Static SPA
|
||||
# ---------------------------------------------------------------------------
|
||||
# Directory of the built frontend (index.html, _app/, fonts, service worker).
|
||||
# When set, the server serves the SPA and the API on the same port, with a
|
||||
# fallback to index.html for client-side routes. Leave empty in local
|
||||
# development — the Vite dev server serves the UI separately. The Docker image
|
||||
# sets this to /app/static.
|
||||
STATIC_DIR=
|
||||
# Leave UNSET here. The Docker image already serves the built SPA from
|
||||
# /app/static and compose pins STATIC_DIR for the container — an empty value in
|
||||
# .env would be injected into the container and disable SPA serving. Set this
|
||||
# only for a bare-metal deploy where the Go server serves a built SPA; leave it
|
||||
# unset in local dev, where the Vite dev server serves the UI.
|
||||
# STATIC_DIR=/path/to/frontend/build
|
||||
|
||||
Reference in New Issue
Block a user