Files
stpweb/vue/Dockerfile
T
adamfandClaude Opus 5 64df70e5d2 Document codebase: comments, per-area READMEs, deployment guide
Readability pass across all four areas of the stack. Comments explain why
rather than what, concentrated at the points where behaviour is non-obvious:
concurrency, caching, auth, scraping and nginx templating.

Backend: doc comments on every exported declaration across handlers,
services, models and resolvers. Resolver commentary lives inside function
bodies so gqlgen does not strip it on regeneration; schema files use #
comments rather than description blocks so introspection output is
unchanged. Extracted the duplicated auth-cookie blocks into helpers.

Frontend: header comments on every component, store and view, including
STATUS: notes marking which of the parallel/legacy views are still live.
Documented the non-reactive animation-state pattern, the homeData hub and
the WebSocket stale-socket guard. Removed a few dead imports and named the
reconnect-backoff and poll-interval constants.

Python: module and function docstrings covering the Travelodge scraping
contract, the deadline threading, the two-executor concurrency and the
NDJSON streaming protocol.

Infra: header blocks on every compose file, nginx template, Dockerfile and
entrypoint, covering the config selection, envsubst allow-lists, rate-limit
semantics and volume persistence. Hoisted the duplicated envsubst variable
list in nginx/entrypoint.sh.

New: backend/README.md, python/README.md, DEPLOYMENT.md, .env.example,
backend/graph/doc.go. Refreshed vue/README.md. Corrected CLAUDE.md, which
stated a 24h access token where main.go sets 7 days.

No behaviour change. go build/vet, vite build, py_compile and docker
compose config all pass.

Co-Authored-By: Claude Opus 5 <[email protected]>
2026-09-16 15:57:48 +01:00

53 lines
2.5 KiB
Docker

# =============================================================================
# Vue frontend image — compiles Rust to WASM, then builds the SPA.
#
# THIS IS A BUILD CONTAINER, NOT A SERVER. In production the container runs
# `vite build` into /output (the shared vue_dist volume) and EXITS. nginx then
# serves those files. Seeing `vue` as Exited(0) in `docker compose ps` is the
# success case, not a failure. The dev override replaces the CMD with the Vite
# dev server, and then it does stay running.
#
# STAGE 1 — WASM
# Builds crates/stp_wasm with wasm-pack into src/wasm. Only that crate
# directory is copied in, so touching Vue source never invalidates the (slow)
# Rust layer. The two cache mounts persist the cargo registry and the Rust
# target directory between builds on the host — on a Raspberry Pi this turns
# a very long compile into an incremental one. src/wasm is gitignored: it is
# generated, never committed.
#
# STAGE 2 — Vue
# package.json + package-lock.json are copied first so `npm ci` is cached
# independently of source changes; the npm cache is also a BuildKit cache
# mount. `npm ci` (not `npm install`) installs exactly the lockfile, so a
# rebuild can never silently pick up a different dependency version.
# `make` and `git` are installed because some npm dependencies build native
# code or resolve git URLs during install.
#
# --emptyOutDir is required: /output is a mounted volume, and vite refuses to
# clear a directory outside the project root without it. Without the flag,
# stale assets from a previous build would accumulate and be served.
#
# Note stage 2 is not named and is the final stage; both base images are
# multi-arch so this builds on the Pi unchanged.
# =============================================================================
# Stage 1: Build WASM from Rust
FROM rust:slim AS wasm-builder
RUN rustup target add wasm32-unknown-unknown \
&& cargo install wasm-pack
WORKDIR /wasm
COPY crates/stp_wasm/ crates/stp_wasm/
RUN --mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=/wasm/crates/stp_wasm/target \
wasm-pack build crates/stp_wasm --target web --out-dir ../../src/wasm
# Stage 2: Build Vue frontend
FROM node:22-slim
RUN apt-get update && apt-get install -y make git && rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY package.json package-lock.json ./
RUN --mount=type=cache,target=/root/.npm \
npm ci
COPY . .
COPY --from=wasm-builder /wasm/src/wasm/ src/wasm/
CMD ["sh", "-c", "npx vite build --outDir /output --emptyOutDir"]