Some checks failed
CI/CD Pipeline / Run Tests (push) Failing after 11m9s
CI/CD Pipeline / Security Scan (push) Has been skipped
CI/CD Pipeline / Build Docker Image (push) Has been skipped
CI/CD Pipeline / Deploy to Staging (push) Has been skipped
CI/CD Pipeline / Deploy to Production (push) Has been skipped
CI/CD Pipeline / Notify Results (push) Successful in 31s
55 lines
1.2 KiB
YAML
55 lines
1.2 KiB
YAML
version: '3.8'
|
|
|
|
services:
|
|
rust-user-api:
|
|
image: docker.io/your-username/rust-user-api:latest
|
|
container_name: rust-user-api-prod
|
|
ports:
|
|
- "8080:3000"
|
|
volumes:
|
|
- ./data:/app/data
|
|
- ./logs:/app/logs
|
|
environment:
|
|
- RUST_LOG=warn
|
|
- RUST_BACKTRACE=1
|
|
- DATABASE_URL=/app/data/production.db
|
|
- JWT_SECRET=${JWT_SECRET:-your-super-secret-jwt-key-change-this-in-production}
|
|
- SERVER_HOST=0.0.0.0
|
|
- SERVER_PORT=3000
|
|
restart: always
|
|
deploy:
|
|
resources:
|
|
limits:
|
|
memory: 512M
|
|
cpus: '0.5'
|
|
reservations:
|
|
memory: 256M
|
|
cpus: '0.25'
|
|
healthcheck:
|
|
test: ["CMD", "curl", "-f", "http://localhost:3000/health"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
start_period: 40s
|
|
|
|
# 可选:添加反向代理
|
|
nginx:
|
|
image: nginx:alpine
|
|
container_name: rust-api-nginx
|
|
ports:
|
|
- "80:80"
|
|
- "443:443"
|
|
volumes:
|
|
- ./nginx.conf:/etc/nginx/nginx.conf:ro
|
|
- ./ssl:/etc/nginx/ssl:ro
|
|
depends_on:
|
|
- rust-user-api
|
|
restart: always
|
|
profiles:
|
|
- with-nginx
|
|
|
|
volumes:
|
|
data:
|
|
driver: local
|
|
logs:
|
|
driver: local |