875743369d
- Add multi-stage Dockerfile for Next.js standalone build - Add docker-compose.yml with app and MySQL 8.0 services - Add .dockerignore for optimized builds - Update next.config.ts with standalone output
53 lines
1.2 KiB
YAML
53 lines
1.2 KiB
YAML
services:
|
|
app:
|
|
build:
|
|
context: .
|
|
dockerfile: Dockerfile
|
|
container_name: recipe_tool_app
|
|
restart: unless-stopped
|
|
ports:
|
|
- "3000:3000"
|
|
environment:
|
|
- NODE_ENV=production
|
|
- DB_HOST=db
|
|
- DB_PORT=3306
|
|
- DB_USER=${DB_USER:-root}
|
|
- DB_PASSWORD=${DB_PASSWORD:-123456}
|
|
- DB_NAME=${DB_NAME:-recipe_tools}
|
|
- AI_API_KEY=${AI_API_KEY}
|
|
- AI_BASE_URL=${AI_BASE_URL:-https://api.openai.com/v1}
|
|
- AI_MODEL=${AI_MODEL:-gpt-3.5-turbo}
|
|
depends_on:
|
|
db:
|
|
condition: service_healthy
|
|
networks:
|
|
- recipe_network
|
|
|
|
db:
|
|
image: mysql:8.0
|
|
container_name: recipe_tool_db
|
|
restart: unless-stopped
|
|
environment:
|
|
- MYSQL_ROOT_PASSWORD=${DB_PASSWORD:-123456}
|
|
- MYSQL_DATABASE=${DB_NAME:-recipe_tools}
|
|
ports:
|
|
- "3306:3306"
|
|
volumes:
|
|
- mysql_data:/var/lib/mysql
|
|
# 初始化脚本(可选)
|
|
# - ./docker/mysql/init.sql:/docker-entrypoint-initdb.d/init.sql
|
|
healthcheck:
|
|
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
networks:
|
|
- recipe_network
|
|
|
|
networks:
|
|
recipe_network:
|
|
driver: bridge
|
|
|
|
volumes:
|
|
mysql_data:
|