2.5 KiB
2.5 KiB
Docker deployment (make up/down)
Context
- Project: VuePress v2 static blog (Vite).
- Goal: one-command production deployment and teardown via
make upandmake down. - Hosting: root path
/. - Port mapping: host
6666-> container80.
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.jsonis present; builds usenpm 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.
- Stage 1 (build): Node image installs dependencies and runs
docker-compose.ymlmanages a single service (e.g.,myblog).Makefilewraps 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, runnpm 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
/.
- Copy
.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
- Operator runs
make up. - Docker builds image (install deps -> build static site).
- Nginx container starts and serves static files.
- Operator runs
make downto stop and remove the service.
Error handling
- Build failures (dependency install or VuePress build) cause
make upto fail and exit. - Compose output provides the error details for diagnosis.
Verification
- Access
http://<host>:6666/and confirm the site loads. - Optional:
docker compose logs -ffor 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).