From 9e59e1dbea6cb6cbb91ec52a0454fc4d73053dd0 Mon Sep 17 00:00:00 2001 From: liumangmang Date: Mon, 30 Mar 2026 17:11:36 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20=E5=AE=8C=E6=88=90XFCE=E7=BB=88?= =?UTF-8?q?=E7=AB=AF=E5=BF=AB=E6=8D=B7=E6=8C=87=E4=BB=A4=E6=96=87=E7=AB=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../specs/2026-03-26-docker-deploy-design.md | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 docs/superpowers/specs/2026-03-26-docker-deploy-design.md diff --git a/docs/superpowers/specs/2026-03-26-docker-deploy-design.md b/docs/superpowers/specs/2026-03-26-docker-deploy-design.md new file mode 100644 index 0000000..b8b9efe --- /dev/null +++ b/docs/superpowers/specs/2026-03-26-docker-deploy-design.md @@ -0,0 +1,75 @@ +# Docker deployment (make up/down) + +## Context +- Project: VuePress v2 static blog (Vite). +- Goal: one-command production deployment and teardown via `make up` and `make down`. +- Hosting: root path `/`. +- Port mapping: host `6666` -> container `80`. + +## Goals +- Provide a reproducible, production-grade deployment using Docker. +- Keep operator commands minimal (`make up`, `make down`). +- Ensure build failures fail fast and are visible. + +## Non-goals +- No development-mode container (`vuepress-vite dev`). +- No additional runtime dependencies besides Docker. +- No advanced orchestration (k8s, swarm). + +## Assumptions +- Docker Engine and Docker Compose v2 are available on the host. +- `package-lock.json` is present; builds use `npm ci`. + +## Proposed architecture +- Multi-stage Docker image: + - Stage 1 (build): Node image installs dependencies and runs `docs:build`. + - Stage 2 (run): Nginx serves the generated static files. +- `docker-compose.yml` manages a single service (e.g., `myblog`). +- `Makefile` wraps compose commands for consistent UX. + +## Components +### Dockerfile +- Base images: `node:20-alpine` (build), `nginx:1.25-alpine` (run). +- Stage 1: + - Workdir set to app root. + - Copy `package.json` + `package-lock.json`, run `npm ci`. + - Copy source and run `npm run docs:build`. +- Stage 2: + - Copy `src/.vuepress/dist/` to `/usr/share/nginx/html`. + - Use default Nginx config for root `/`. + +### .dockerignore +- Exclude: `node_modules`, `dist`, `src/.vuepress/dist`, `.git`, `*.log`. + +### docker-compose.yml +- Service name: `myblog`. +- Build context: repository root. +- Image name: `myblog:latest`. +- Port mapping: `6666:80`. +- Restart policy: `unless-stopped`. + +### Makefile +- `make up`: `docker compose up -d --build`. +- `make down`: `docker compose down`. +- Optional commands (if desired later): `make logs`, `make ps`, `make rebuild`. + +## Runtime flow +1. Operator runs `make up`. +2. Docker builds image (install deps -> build static site). +3. Nginx container starts and serves static files. +4. Operator runs `make down` to stop and remove the service. + +## Error handling +- Build failures (dependency install or VuePress build) cause `make up` to fail and exit. +- Compose output provides the error details for diagnosis. + +## Verification +- Access `http://:6666/` and confirm the site loads. +- Optional: `docker compose logs -f` for runtime inspection. + +## Security / operations +- No secrets are required. +- Container only exposes HTTP on port 80 inside the compose network. + +## Open questions +- None. All required inputs confirmed (production mode, root path, port 6666).