-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-compose.dev.yml
92 lines (87 loc) · 3.29 KB
/
docker-compose.dev.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
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: CRON JOB
# Defines a service named "cron_service" for running cron jobs.
cron_service:
# Specifies the name of the container as "cron_service".
container_name: cron_service
# Restarts the container unless explicitly stopped.
restart: unless-stopped
# Builds the container using the specified Dockerfile and target.
build:
# Specifies the build context as the current directory.
context: .
# Specifies the path to the Dockerfile for building the container.
dockerfile: ./third_party/docker/go/Dockerfile-cron
# Loads environment variables from the specified .env file.
env_file:
- .env
environment:
ENV: "pro" # Port for the service
# Specifies that this service depends on the "postgresql" service.
depends_on:
- postgresql
# Connects the service to the "service_auth-network" network.
networks:
- service_auth-network
# # TODO: MESSAGE QUEUE
# # Defines a service named "queue_service" for running cron jobs.
queue_service:
# Specifies the name of the container as "queue_service".
container_name: queue_service
# Restarts the container unless explicitly stopped.
restart: unless-stopped
# Builds the container using the specified Dockerfile and target.
build:
# Specifies the build context as the current directory.
context: .
# Specifies the path to the Dockerfile for building the container.
dockerfile: ./third_party/docker/go/Dockerfile-queue
# Loads environment variables from the specified .env file.
env_file:
- .env
environment:
ENV: "pro" # Port for the service
# Specifies that this service depends on the "postgresql" service.
depends_on:
- postgresql
# Connects the service to the "service_auth-network" network.
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