-
Notifications
You must be signed in to change notification settings - Fork 0
/
pwd.yml
308 lines (287 loc) · 9.17 KB
/
pwd.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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
version: "3"
services:
# traefik:
# image: traefik:v2.5
# command:
# - --api.insecure=true
# - --providers.docker=true
# - --providers.docker.exposedbydefault=false
# - --entrypoints.web.address=:80
# - --entrypoints.websecure.address=:443
# - --entrypoints.webdashboard.address=:8081
# - --certificatesresolvers.myresolver.acme.httpchallenge=true
# - --certificatesresolvers.myresolver.acme.httpchallenge.entrypoint=web
# - --certificatesresolvers.myresolver.acme.email=email@yourdomain.in
# - --certificatesresolvers.myresolver.acme.storage=/letsencrypt/acme.json
# # Add dashboard configuration
# - --api.dashboard=true
# ports:
# - "80:80"
# - "443:443"
# - "8081:8081"
# volumes:
# - /var/run/docker.sock:/var/run/docker.sock:ro
# - ./letsencrypt:/letsencrypt
# labels:
# # Dashboard configuration
# - "traefik.http.routers.api.rule=Host(`traefik.localhost`)"
# - "traefik.http.routers.api.service=api@internal"
# - "traefik.http.routers.api.entrypoints=web"
# - "traefik.http.services.api.loadbalancer.server.port=8080"
# - "traefik.http.routers.api.entrypoints=webdashboard"
# custom-domain:
# image: caddy:2
# command:
# - caddy
# - reverse-proxy
# - --to
# - frontend:8080
# - --from
# - :2016
# labels:
# - traefik.enable=true
# - traefik.docker.network=traefik-public
# - traefik.http.services.custom-domain.loadbalancer.server.port=2016
# - traefik.http.routers.custom-domain.service=custom-domain
# - traefik.http.routers.custom-domain.entrypoints=web,websecure
# - traefik.http.routers.custom-domain.rule=Host(`erp.yourdomain.in`)
# - traefik.http.middlewares.custom-domain.headers.customrequestheaders.Host=erp.yourdomain.in
# - traefik.http.routers.custom-domain.middlewares=custom-domain
# - traefik.http.routers.custom-domain.tls.certresolver=myresolver
# networks:
# - traefik-public
# - bench-network
nginx:
image: nginx:latest
volumes:
- ./nginx-config:/etc/nginx/conf.d
- ./letsencrypt:/etc/letsencrypt
- ./nginx-webroot:/usr/share/nginx/html # Mounting a volume for the webroot
ports:
- "80:80"
- "443:443"
entrypoint:
- /bin/sh
- -c
- |
if [ ! -f "/etc/letsencrypt/live/erp.yourdomain.in/fullchain.pem" ]; then
certbot certonly --webroot -w /usr/share/nginx/html -d erp.yourdomain.in --non-interactive --agree-tos --email [email protected]
fi
nginx -g "daemon off;"
depends_on:
- nginx-config-init
- frontend
nginx-config-init:
image: busybox
volumes:
- ./nginx-config:/etc/nginx/conf.d
command: /bin/sh -c "echo 'server { listen 80; server_name erp.yourdomain.in; root /usr/share/nginx/html; location / { proxy_pass http://frontend:8080; proxy_set_header Host $$host; proxy_set_header X-Real-IP $$remote_addr; location ~ /.well-known { allow all; } }' > /etc/nginx/conf.d/default.conf && echo 'server { listen 443 ssl; server_name erp.yourdomain.in; ssl_certificate /etc/letsencrypt/live/erp.yourdomain.in/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/erp.yourdomain.in/privkey.pem; root /usr/share/nginx/html; location / { proxy_pass http://frontend:8080; proxy_set_header Host $$host; proxy_set_header X-Real-IP $$remote_addr; } }' >> /etc/nginx/conf.d/default.conf"
certbot:
image: certbot/certbot
volumes:
- ./letsencrypt:/etc/letsencrypt
- ./nginx-webroot:/usr/share/nginx/html
entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew; sleep 12h & wait $${!}; done;'"
backend:
image: frappe/erpnext:v14.43.0
deploy:
restart_policy:
condition: on-failure
volumes:
- sites:/home/frappe/frappe-bench/sites
- logs:/home/frappe/frappe-bench/logs
configurator:
image: frappe/erpnext:v14.43.0
deploy:
restart_policy:
condition: none
entrypoint:
- bash
- -c
command:
- >
ls -1 apps > sites/apps.txt;
bench set-config -g db_host $$DB_HOST;
bench set-config -gp db_port $$DB_PORT;
bench set-config -g redis_cache "redis://$$REDIS_CACHE";
bench set-config -g redis_queue "redis://$$REDIS_QUEUE";
bench set-config -g redis_socketio "redis://$$REDIS_SOCKETIO";
bench set-config -gp socketio_port $$SOCKETIO_PORT;
environment:
DB_HOST: db
DB_PORT: "3306"
REDIS_CACHE: redis-cache:6379
REDIS_QUEUE: redis-queue:6379
REDIS_SOCKETIO: redis-socketio:6379
SOCKETIO_PORT: "9000"
volumes:
- sites:/home/frappe/frappe-bench/sites
- logs:/home/frappe/frappe-bench/logs
create-site:
image: frappe/erpnext:v14.43.0
deploy:
restart_policy:
condition: none
volumes:
- sites:/home/frappe/frappe-bench/sites
- logs:/home/frappe/frappe-bench/logs
entrypoint:
- bash
- -c
command:
- >
wait-for-it -t 120 db:3306;
wait-for-it -t 120 redis-cache:6379;
wait-for-it -t 120 redis-queue:6379;
wait-for-it -t 120 redis-socketio:6379;
export start=`date +%s`;
until [[ -n `grep -hs ^ sites/common_site_config.json | jq -r ".db_host // empty"` ]] && \
[[ -n `grep -hs ^ sites/common_site_config.json | jq -r ".redis_cache // empty"` ]] && \
[[ -n `grep -hs ^ sites/common_site_config.json | jq -r ".redis_queue // empty"` ]];
do
echo "Waiting for sites/common_site_config.json to be created";
sleep 5;
if (( `date +%s`-start > 120 )); then
echo "could not find sites/common_site_config.json with required keys";
exit 1
fi
done;
echo "sites/common_site_config.json found";
bench new-site erp.yourdomain.in --no-mariadb-socket --admin-password=admin --db-root-password=admin --install-app erpnext --set-default;
db:
image: mariadb:10.6
healthcheck:
test: mysqladmin ping -h localhost --password=admin
interval: 1s
retries: 15
deploy:
restart_policy:
condition: on-failure
command:
- --character-set-server=utf8mb4
- --collation-server=utf8mb4_unicode_ci
- --skip-character-set-client-handshake
- --skip-innodb-read-only-compressed # Temporary fix for MariaDB 10.6
environment:
MYSQL_ROOT_PASSWORD: admin
volumes:
- db-data:/var/lib/mysql
ports:
- "3306:3306"
frontend:
image: frappe/erpnext:v14.43.0
deploy:
restart_policy:
condition: on-failure
command:
- nginx-entrypoint.sh
environment:
BACKEND: backend:8000
FRAPPE_SITE_NAME_HEADER: erp.yourdomain.in
SOCKETIO: websocket:9000
UPSTREAM_REAL_IP_ADDRESS: 127.0.0.1
UPSTREAM_REAL_IP_HEADER: X-Forwarded-For
UPSTREAM_REAL_IP_RECURSIVE: "off"
PROXY_READ_TIMEOUT: 120
CLIENT_MAX_BODY_SIZE: 50m
volumes:
- sites:/home/frappe/frappe-bench/sites
- logs:/home/frappe/frappe-bench/logs
ports:
- "8080:8080"
queue-default:
image: frappe/erpnext:v14.43.0
deploy:
restart_policy:
condition: on-failure
command:
- bench
- worker
- --queue
- default
volumes:
- sites:/home/frappe/frappe-bench/sites
- logs:/home/frappe/frappe-bench/logs
queue-long:
image: frappe/erpnext:v14.43.0
deploy:
restart_policy:
condition: on-failure
command:
- bench
- worker
- --queue
- long
volumes:
- sites:/home/frappe/frappe-bench/sites
- logs:/home/frappe/frappe-bench/logs
queue-short:
image: frappe/erpnext:v14.43.0
deploy:
restart_policy:
condition: on-failure
command:
- bench
- worker
- --queue
- short
volumes:
- sites:/home/frappe/frappe-bench/sites
- logs:/home/frappe/frappe-bench/logs
redis-queue:
image: redis:6.2-alpine
deploy:
restart_policy:
condition: on-failure
volumes:
- redis-queue-data:/data
redis-cache:
image: redis:6.2-alpine
deploy:
restart_policy:
condition: on-failure
volumes:
- redis-cache-data:/data
redis-socketio:
image: redis:6.2-alpine
deploy:
restart_policy:
condition: on-failure
volumes:
- redis-socketio-data:/data
scheduler:
image: frappe/erpnext:v14.43.0
deploy:
restart_policy:
condition: on-failure
command:
- bench
- schedule
volumes:
- sites:/home/frappe/frappe-bench/sites
- logs:/home/frappe/frappe-bench/logs
websocket:
image: frappe/erpnext:v14.43.0
deploy:
restart_policy:
condition: on-failure
command:
- node
- /home/frappe/frappe-bench/apps/frappe/socketio.js
volumes:
- sites:/home/frappe/frappe-bench/sites
- logs:/home/frappe/frappe-bench/logs
networks:
traefik-public:
driver: bridge
bench-network:
name: bench-network
driver: bridge
volumes:
nginx-webroot:
db-data:
redis-queue-data:
redis-cache-data:
redis-socketio-data:
sites:
logs: