Added: Dockerfile, support for configurations from env

This commit is contained in:
KamilM1205 2026-01-04 01:04:20 +04:00
parent ea8ab7c0ed
commit c1ed822293
3 changed files with 117 additions and 10 deletions

76
docker-compose.yml Normal file
View file

@ -0,0 +1,76 @@
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: