-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-compose.pro.yml
103 lines (97 loc) · 3.26 KB
/
docker-compose.pro.yml
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
version: "3.8"
services:
# TODO: POSTGRESQL
postgresql:
container_name: postgresql
# Image version PG
image: postgres:latest
# Not restart when db crashes
restart: unless-stopped
environment:
POSTGRES_DB: "${POSTGRES_DB}" # Database name from environment variable
POSTGRES_USER: "${POSTGRES_USER}" # Username from environment variable
POSTGRES_PASSWORD: "${POSTGRES_PASSWORD}" # Password from environment variable
PGDATA: "/data/postgres" # Location of the PostgreSQL data files
volumes:
- db_data/:/var/lib/postgresql/data/postgres:ro # Mount a volume for database data in read-only mode
- ./migrations:/docker-entrypoint-initdb.d # Initial SQL script for database setup
env_file:
- .env # Load environment variables from .env file
ports:
- "${POSTGRES_PORT_MAPPING}:${POSTGRES_PORT}" # Map the container port to the host port
networks:
- service_auth-network # Connect to the custom network
healthcheck:
test: [
"CMD-SHELL",
"sh -c 'pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}'", # Check if PostgreSQL is ready
]
interval: 10s # Interval between health checks
timeout: 3s # Health check timeout
retries: 3 # Number of retries before marking the service as unhealthy
# TODO: GO
# App Service
service_auth:
# Name container
container_name: service_auth
# Configuration for building the docker image for the service
restart: unless-stopped
# Image production
image: nguyentientai/go-secure-auth-pro:lastest
# Load environment variables from .env file
env_file:
- .env
environment:
ENV: "pro" # Port for the service
ports:
- "${PORT}:${PORT}" # Map the container port to the host port
depends_on:
- postgresql # This service depends on PostgreSQL. Start PostgreSQL first.
networks:
- service_auth-network # Connect to the custom network
healthcheck:
test: [
"CMD",
"sh",
"-c",
"curl -sSf http://${HOST}:${PORT}/ping > /dev/null",
] # Health check to verify the app is running
interval: 60s # Interval between health checks
timeout: 2s # Health check timeout
retries: 3 # Number of retries before marking the service as unhealthy
# TODO: CRON JOB
# Defines a cron service that runs scheduled tasks
service_cron:
container_name: service_cron
restart: unless-stopped
image: nguyentientai/go_cronjob_auth:lastest
env_file:
- .env
depends_on:
- postgresql
environment:
ENV: "pro" # Port for the service
networks:
- service_auth-network
# TODO: MESSAGE QUEUE
# Defines a service named "service_queue" for a message queue in a production environment.
service_queue:
container_name: service_queue
restart: unless-stopped
image: nguyentientai/go_message_queue_auth:lastest
env_file:
- .env
depends_on:
- postgresql
environment:
ENV: "pro" # Specifies the environment variable "ENV" with the value "pro" for the service
networks:
- service_auth-network
# Use local driver for the volume
volumes:
db_data:
driver: local
# Use bridge network driver
networks:
service_auth-network:
driver: bridge