76 lines
1.5 KiB
YAML
76 lines
1.5 KiB
YAML
version: '3.8'
|
|
|
|
services:
|
|
app:
|
|
build: .
|
|
container_name: blog_backend
|
|
ports:
|
|
- "8080:8080"
|
|
environment:
|
|
- GIN_MODE=release
|
|
- PORT=8080
|
|
- DATABASE_URL=postgres://userpg:1205@localhost:5432/58blog
|
|
depends_on:
|
|
- db
|
|
- redis
|
|
networks:
|
|
- app-network
|
|
volumes:
|
|
- ./logs:/app/logs
|
|
- ./uploads:/app/uploads
|
|
restart: unless-stopped
|
|
healthcheck:
|
|
test: ["CMD", "curl", "-f", "http://localhost:8080/health"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
|
|
db:
|
|
image: postgres:15-alpine
|
|
container_name: gin-db
|
|
environment:
|
|
- POSTGRES_USER=appuser
|
|
- POSTGRES_PASSWORD=secretpassword
|
|
- POSTGRES_DB=mydb
|
|
ports:
|
|
- "5432:5432"
|
|
volumes:
|
|
- postgres_data:/var/lib/postgresql/data
|
|
- ./init.sql:/docker-entrypoint-initdb.d/init.sql
|
|
networks:
|
|
- app-network
|
|
restart: unless-stopped
|
|
|
|
redis:
|
|
image: redis:7-alpine
|
|
container_name: gin-redis
|
|
ports:
|
|
- "6379:6379"
|
|
volumes:
|
|
- redis_data:/data
|
|
networks:
|
|
- app-network
|
|
restart: unless-stopped
|
|
|
|
nginx:
|
|
image: nginx:alpine
|
|
container_name: gin-nginx
|
|
ports:
|
|
- "80:80"
|
|
- "443:443"
|
|
volumes:
|
|
- ./nginx.conf:/etc/nginx/nginx.conf:ro
|
|
- ./ssl:/etc/nginx/ssl:ro
|
|
depends_on:
|
|
- app
|
|
networks:
|
|
- app-network
|
|
restart: unless-stopped
|
|
|
|
networks:
|
|
app-network:
|
|
driver: bridge
|
|
|
|
volumes:
|
|
postgres_data:
|
|
redis_data:
|