AgentSkillsCN

docker

为 Luxia 电商平台构建单容器部署方案,集成 PostgreSQL、Nginx 与 Supervisor。 当您需要修改 Dockerfile、docker-compose.yml、nginx.conf、supervisord.conf,或部署脚本时,可使用此技能。

SKILL.md
--- frontmatter
name: docker
description: |
  Builds single-container deployments with PostgreSQL, Nginx, and Supervisor for the Luxia e-commerce platform.
  Use when: modifying Dockerfile, docker-compose.yml, nginx.conf, supervisord.conf, or deployment scripts.
allowed-tools: Read, Edit, Write, Glob, Grep, Bash

Docker Skill

Single-container architecture bundling PostgreSQL 14, Node.js 20 backend, Nginx reverse proxy, and Supervisor process manager. Multi-stage builds optimize image size while supporting both AMD64 and ARM64 architectures.

Quick Start

Build and Run

bash
# Docker Compose (recommended)
docker-compose up -d

# Manual build
docker build -t luxia-ecommerce:latest .
docker run -d -p 80:80 \
  -e JWT_SECRET=$(openssl rand -base64 32) \
  -e DB_PASSWORD=secure_password \
  -e POSTGRES_PASSWORD=secure_password \
  -v luxia-postgres:/var/lib/postgresql/data \
  -v luxia-uploads:/app/backend/uploads \
  luxia-ecommerce:latest

Multi-Architecture Build

bash
./docker/build-multiarch.sh
# Or with registry:
REGISTRY=your.registry.com ./docker/build-multiarch.sh

Key Concepts

ConceptLocationPurpose
Multi-stage buildDockerfileSeparate frontend/backend builders, final Ubuntu runtime
Supervisordocker/supervisord.confManages PostgreSQL → migrations → backend → nginx startup order
Nginx proxydocker/nginx.confRoutes /api/* to backend, serves static files
Health checkDockerfile:113Verifies /api/health endpoint

Common Patterns

Service Priority Order

Supervisor starts services in priority order:

ini
# docker/supervisord.conf
[program:postgresql]
priority=1      # Start first

[program:migrations]
priority=2      # Run after DB ready

[program:backend]
priority=3      # Start after migrations

[program:nginx]
priority=4      # Start last

Volume Persistence

yaml
# docker-compose.yml
volumes:
  - postgres_data:/var/lib/postgresql/data  # Database
  - uploads_data:/app/backend/uploads        # User uploads

Environment Variables

Critical variables for production:

VariablePurpose
JWT_SECRETToken signing (use openssl rand -base64 32)
DB_PASSWORDPostgreSQL password
POSTGRES_PASSWORDMust match DB_PASSWORD

See Also

  • docker - Dockerfile patterns and multi-stage builds
  • deployment - Production deployment checklist
  • monitoring - Logging and health checks

Related Skills

For PostgreSQL configuration details, see the postgresql skill. For backend service patterns, see the express skill. For Node.js runtime specifics, see the node skill.