-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
80 lines (76 loc) · 2.18 KB
/
Copy pathdocker-compose.yml
File metadata and controls
80 lines (76 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
services:
backend:
container_name: go-rest-api-template
build:
context: .
dockerfile: Dockerfile
ports:
- "127.0.0.1:8001:8001"
depends_on:
db:
condition: service_healthy
mongo:
condition: service_healthy
redis:
condition: service_healthy
environment:
POSTGRES_DB: go_app_dev
POSTGRES_HOST: dockerPostgres
POSTGRES_USER: docker
POSTGRES_PASSWORD: password
POSTGRES_PORT: 5435
# Load from a project-root `.env` file (Compose interpolates it) or from the shell environment.
JWT_SECRET_KEY: ${JWT_SECRET_KEY:?JWT_SECRET_KEY must be set - copy .env.example to .env and fill secrets}
API_SECRET_KEY: ${API_SECRET_KEY:?API_SECRET_KEY must be set - copy .env.example to .env and fill secrets}
REDIS_HOST: redis
MONGODB_URI: mongodb://mongo:27017
# Enables HSTS/CSP and XSS middleware in pkg/api/router.go (Gin release mode).
GIN_MODE: release
db:
image: postgres:14.17-alpine
restart: always
container_name: dockerPostgres
volumes:
# Named volume (aligned with mongo_data); avoids bind-mounting ./.dbdata into the image context.
- postgres_data:/var/lib/postgresql/data
ports:
- "127.0.0.1:5435:5435"
environment:
- POSTGRES_DB=go_app_dev
- POSTGRES_USER=docker
- POSTGRES_PASSWORD=password
command: -p 5435
healthcheck:
test: ["CMD-SHELL", "pg_isready -U docker -d go_app_dev -p 5435"]
interval: 5s
timeout: 5s
retries: 20
start_period: 10s
redis:
image: redis:7.4.2-alpine
ports:
- "127.0.0.1:6379:6379"
container_name: dockerRedis
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 3s
retries: 10
start_period: 5s
mongo:
image: mongo:7.0.15
container_name: dockerMongo
volumes:
- mongo_data:/data/db
ports:
- "127.0.0.1:27017:27017"
restart: always
healthcheck:
test: ["CMD", "mongosh", "--quiet", "--eval", "db.runCommand({ ping: 1 }).ok"]
interval: 5s
timeout: 5s
retries: 20
start_period: 10s
volumes:
mongo_data:
postgres_data: