-
Notifications
You must be signed in to change notification settings - Fork 0
/
a.yml
118 lines (108 loc) · 3.49 KB
/
a.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
version: "3.9"
services:
nginx:
image: nginx:stable-alpine
container_name: nginx
restart: always
ports:
- "5000:80"
volumes:
- ./client/dist:/usr/share/nginx/html:ro
# this 👇 is added via GPT4, is it useful to make it in both a && b compose files?
- ./server/config/nginx/default.conf:/etc/nginx/conf.d/default.conf:ro
depends_on:
- app
app:
build:
context: ./server
dockerfile: Dockerfile
image: baderidris/e-commerce
restart: always
environment:
- PORT=3000
depends_on:
- mongo
# - psql_master
mongo:
image: mongo:4.4
container_name: mongo
restart: always
environment:
- MONGO_INITDB_ROOT_USERNAME=Bader
- MONGO_INITDB_ROOT_PASSWORD=myPassword
volumes:
- mongo-db:/data/db:rw # 🔴chmod +x if (node.length > 1)🔴
- ./server/config/mongo/mongod.conf:/etc/mongod.conf:ro
command: mongod --config /etc/mongod.conf # Specify the custom configuration file path
redis:
image: redis:alpine3.18
container_name: redis
restart: always
volumes:
- ./server/config/redis/redis.conf:/usr/local/etc/redis/redis.conf:ro
# - ./config/redis/.overcommit_memory:/proc/sys/vm/overcommit_memory
# command:
# - sh -c "echo 1 > /proc/sys/vm/overcommit_memory"
# - ./redis-server /usr/local/etc/redis/redis.conf
# - redis-server AUTH default myPassword
# - AUTH default myPassword
#! added by chatGPT, check it out
command: redis-server /usr/local/etc/redis/redis.conf --requirepass myPassword
# postgres:
# image: postgres:16-alpine3.18
# #! An important concept is using master/slave duplication
# #? master => insert update delete && slaves => read
# #! or even multi-master or other concepts to handle DB high requests
# container_name: psql
# restart: always
# environment:
# POSTGRES_PASSWORD: example
# POSTGRES_DB: articles
# volumes:
# - psql-data:/var/lib/postgresql/data:rw # 🔴chmod +x if (node.length > 1)🔴
# - ./server/config/psql/postgresql.conf:/etc/postgresql/postgresql.conf:ro
# adminer: # i think it's not important to have
# image: adminer
# restart: always
# ports:
# - 8080:8080
psql_master:
image: postgres:16-alpine3.18
container_name: psql_master
restart: always
environment:
POSTGRES_PASSWORD: example
POSTGRES_DB: articles
POSTGRES_USER: postgres
REPLICATION_USER: rep_user
REPLICATION_PASSWORD: rep_pass
volumes:
- psql-master-data:/var/lib/postgresql/data:rw
- ./server/config/psql/postgresql.conf:/etc/postgresql/postgresql.conf:ro
- ./server/config/psql/pg_hba.conf:/var/lib/postgresql/data/pg_hba.conf:ro
command: postgres -c config_file=/etc/postgresql/postgresql.conf
psql_slave:
image: postgres:16-alpine3.18
container_name: psql_slave
restart: always
environment:
POSTGRES_PASSWORD: example
POSTGRES_USER: postgres
REPLICATION_USER: rep_user
REPLICATION_PASSWORD: rep_pass
POSTGRES_DB: articles
volumes:
- psql-slave-data:/var/lib/postgresql/data:rw
depends_on:
- psql_master
command: |
bash -c "
until pg_basebackup -h psql_master -D /var/lib/postgresql/data -U rep_user -vP -W; do
echo 'Waiting for master to connect...'
sleep 1
done &&
postgres -c config_file=/var/lib/postgresql/data/postgresql.conf
"
volumes:
mongo-db:
psql-data: