一键导入
docker-init
Initialize Docker development environment with database migrations. Use for first-time setup or after pulling major changes.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Initialize Docker development environment with database migrations. Use for first-time setup or after pulling major changes.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Generate CRUD API endpoints following OpenOrder patterns (Fastify, Prisma, Zod, RBAC)
Scaffold new POS or payment adapter implementations. Use when adding support for Square, Toast, Clover, Stripe, or other integrations.
Create conventional commits following OpenOrder standards with AGPL co-authoring
Run comprehensive checks across the entire monorepo. Use before creating PRs or after making cross-package changes.
Create and validate Prisma database migrations. Use after schema.prisma changes or when adding new database features.
Audit codebase for security vulnerabilities, secret leakage, dependency risks, and configuration issues. Use before commits, when adding dependencies, or reviewing PRs. Enforces zero-secrets policy, dependency isolation, and secure build practices.
| name | docker-init |
| description | Initialize Docker development environment with database migrations. Use for first-time setup or after pulling major changes. |
| disable-model-invocation | false |
| allowed-tools | Bash(docker*), Bash(cp*), Read |
This skill initializes the Docker development environment with proper setup steps.
Check Environment Configuration
# Check if .env exists
if [ ! -f .env ]; then
echo "⚠️ .env file not found"
fi
If .env missing:
cp .env.example .envDATABASE_URL - PostgreSQL connection stringREDIS_URL - Redis connection stringAPP_SECRET - Used for JWT signing and config encryptionDB_PASSWORD - Database password for Docker ComposeGenerate APP_SECRET:
openssl rand -base64 32
Example .env:
DATABASE_URL="postgresql://openorder:your_password@localhost:5432/openorder"
REDIS_URL="redis://localhost:6379"
APP_SECRET="<generated-secret-here>"
DB_PASSWORD="your_password"
NODE_ENV="development"
Choose Environment
Ask user:
Which environment do you want to start?
1. Development (recommended for local work)
2. Production (for testing production builds)
Start Docker Services
Development Mode:
docker compose -f docker/docker-compose.yml -f docker/docker-compose.dev.yml up -d
Production Mode:
docker compose -f docker/docker-compose.yml up -d
Services Started:
postgres - PostgreSQL databaseredis - Redis cache/queue backendapi - Fastify API serverstorefront - Next.js customer ordering appdashboard - React SPA for restaurant managementwidget - Embeddable Web ComponentWait for PostgreSQL Readiness
echo "Waiting for PostgreSQL to be ready..."
docker compose exec -T postgres pg_isready -U openorder || sleep 5
Retry up to 30 seconds with 5-second intervals.
Run Database Migrations
echo "Running database migrations..."
docker compose exec api npx prisma migrate deploy
What this does:
apps/api/prisma/migrations/If migration fails:
docker compose psdocker compose logs apiGenerate Prisma Client
docker compose exec api npx prisma generate
Ensures Prisma Client is up-to-date with schema.
Verify Services are Running
docker compose ps
Expected output:
NAME STATUS PORTS
openorder-api Up 30 seconds 0.0.0.0:4000->4000/tcp
openorder-storefront Up 30 seconds 0.0.0.0:3000->3000/tcp
openorder-dashboard Up 30 seconds 0.0.0.0:3001->3001/tcp
openorder-postgres Up 30 seconds 0.0.0.0:5432->5432/tcp
openorder-redis Up 30 seconds 0.0.0.0:6379->6379/tcp
Show Service Endpoints
✅ OpenOrder Development Environment Ready!
Services:
- API: http://localhost:4000
- Storefront: http://localhost:3000
- Dashboard: http://localhost:3001
- PostgreSQL: localhost:5432
- Redis: localhost:6379
Useful commands:
- View logs: docker compose logs -f
- Stop services: docker compose down
- Restart: docker compose restart
- Reset database: docker compose down -v && docker compose up -d
Next steps:
1. Visit http://localhost:3001 to access the dashboard
2. Create a restaurant account
3. Configure menu and payment settings
4. Test ordering at http://localhost:3000/{restaurant-slug}
Health Check
# Test API is responding
curl -f http://localhost:4000/health || echo "⚠️ API not responding yet, give it a few seconds..."
Error: Bind for 0.0.0.0:4000 failed: port is already allocated
# Find process using port
lsof -ti:4000
# Kill process or use different port in docker-compose.yml
# Change: "4000:4000" to "4001:4000"
Error: Can't reach database server
# Check PostgreSQL is running
docker compose ps postgres
# View PostgreSQL logs
docker compose logs postgres
# Verify DATABASE_URL matches docker-compose.yml settings
cat .env | grep DATABASE_URL
Error: Migration failed to apply cleanly
# View detailed migration logs
docker compose logs api
# Reset database (⚠️ DELETES ALL DATA)
docker compose down -v
docker compose up -d
docker compose exec api npx prisma migrate deploy
Error: Cannot find module '@openorder/shared-types'
# Rebuild shared packages
docker compose exec api npm run build
# Or rebuild from scratch
docker compose down
docker compose build --no-cache
docker compose up -d
Frontend (Storefront/Dashboard):
apps/storefront/ or apps/dashboard/ are hot-reloaded automaticallyBackend (API):
apps/api/src/ restart the server automatically via nodemondocker compose logs -f apiShared Packages:
packages/*/src/ require rebuild:
docker compose exec api npm run build
# 1. Edit apps/api/prisma/schema.prisma
# 2. Create migration
docker compose exec api npx prisma migrate dev --name add_feature
# 3. Restart API to pick up new Prisma Client
docker compose restart api
Stop all:
docker compose down
Stop and remove volumes (⚠️ deletes database):
docker compose down -v
Stop specific service:
docker compose stop api
All services:
docker compose logs -f
Specific service:
docker compose logs -f api
docker compose logs -f postgres
Since timestamp:
docker compose logs --since 5m
When testing production builds:
Build images:
docker compose -f docker/docker-compose.yml build
Start in production mode:
docker compose -f docker/docker-compose.yml up -d
Run migrations:
docker compose exec api npx prisma migrate deploy
Verify environment:
docker compose exec api env | grep NODE_ENV
# Should output: NODE_ENV=production
Remove all containers and volumes:
docker compose down -v --remove-orphans
Remove all images:
docker compose down --rmi all
Start fresh:
docker compose down -v
docker compose build --no-cache
docker compose up -d
For production self-hosting:
.env files (.env.production)APP_SECRET (min 32 characters)See docs/deployment.md for full production setup guide.