Multi-stage Dockerfiles for both (build stage with devDependencies, slim production runtime), a root docker-compose.yml wiring them together, and a root .env.example documenting the compose-level vars. The frontend container runs with network_mode: service:backend rather than its own network — VITE_BACKEND_URL is baked into the frontend bundle at build time and used by both the visitor's browser and this container's own server-rendered (SSR) fetches on a page's first load; sharing the backend's network namespace is what lets a single http://localhost:4000 value correctly resolve for both, since no Compose-internal service-name hostname is reachable from a browser and no host-only address is reachable from inside a separate container. Backend gets a healthcheck (plain node -e fetch, no extra deps) so depends_on: condition: service_healthy actually waits for it to be ready rather than just started. backend-data volume persists the SQLite DB, downloaded media, and uploaded widgets across restarts. Added a root README "Docker" section and a root .gitignore for the compose .env file.
33 lines
929 B
Docker
33 lines
929 B
Docker
# syntax=docker/dockerfile:1
|
|
|
|
# --- build stage: compile TypeScript, needs devDependencies (typescript, tsx, @types/node) ---
|
|
FROM node:22-slim AS build
|
|
WORKDIR /app
|
|
|
|
COPY package.json package-lock.json ./
|
|
RUN npm ci
|
|
|
|
COPY . .
|
|
RUN npm run build
|
|
|
|
# --- runtime stage: production deps only, compiled dist/ copied in ---
|
|
FROM node:22-slim AS runtime
|
|
WORKDIR /app
|
|
ENV NODE_ENV=production
|
|
|
|
COPY package.json package-lock.json ./
|
|
RUN npm ci --omit=dev
|
|
|
|
COPY --from=build /app/dist ./dist
|
|
|
|
# SQLite DB, downloaded media, and uploaded-widget files all live under here — mount
|
|
# this as a volume (see docker-compose.yml) so they survive container recreation.
|
|
RUN mkdir -p /app/data
|
|
VOLUME ["/app/data"]
|
|
|
|
EXPOSE 4000
|
|
|
|
# node:sqlite is still an experimental Node API (see storage/db/index.ts) — matches
|
|
# the --experimental-sqlite flag already used by `npm start` in package.json.
|
|
CMD ["node", "--experimental-sqlite", "dist/index.js"]
|