1+ x-custom-image : &custom_image
2+ image : ${IMAGE_NAME:-docker.io/frappe/erpnext}:${VERSION:-version-15}
3+ pull_policy : ${PULL_POLICY:-always}
4+ deploy :
5+ restart_policy :
6+ condition : always
7+
8+ services :
9+ backend :
10+ << : *custom_image
11+ volumes :
12+ - sites:/home/frappe/frappe-bench/sites
13+ networks :
14+ - bench-network
15+ healthcheck :
16+ test :
17+ - CMD
18+ - wait-for-it
19+ - ' 0.0.0.0:8000'
20+ interval : 2s
21+ timeout : 10s
22+ retries : 30
23+
24+ frontend :
25+ << : *custom_image
26+ command :
27+ - nginx-entrypoint.sh
28+ depends_on :
29+ backend :
30+ condition : service_started
31+ required : true
32+ websocket :
33+ condition : service_started
34+ required : true
35+ environment :
36+ BACKEND : backend:8000
37+ FRAPPE_SITE_NAME_HEADER : ${FRAPPE_SITE_NAME_HEADER:-$$host}
38+ SOCKETIO : websocket:9000
39+ UPSTREAM_REAL_IP_ADDRESS : 127.0.0.1
40+ UPSTREAM_REAL_IP_HEADER : X-Forwarded-For
41+ UPSTREAM_REAL_IP_RECURSIVE : " off"
42+ volumes :
43+ - sites:/home/frappe/frappe-bench/sites
44+
45+ networks :
46+ - bench-network
47+
48+ healthcheck :
49+ test :
50+ - CMD
51+ - wait-for-it
52+ - ' 0.0.0.0:8080'
53+ interval : 2s
54+ timeout : 30s
55+ retries : 30
56+
57+ queue-default :
58+ << : *custom_image
59+ command :
60+ - bench
61+ - worker
62+ - --queue
63+ - default
64+ volumes :
65+ - sites:/home/frappe/frappe-bench/sites
66+ networks :
67+ - bench-network
68+ healthcheck :
69+ test :
70+ - CMD
71+ - wait-for-it
72+ - ' redis-queue:6379'
73+ interval : 2s
74+ timeout : 10s
75+ retries : 30
76+ depends_on :
77+ configurator :
78+ condition : service_completed_successfully
79+ required : true
80+
81+ queue-long :
82+ << : *custom_image
83+ command :
84+ - bench
85+ - worker
86+ - --queue
87+ - long
88+ volumes :
89+ - sites:/home/frappe/frappe-bench/sites
90+ networks :
91+ - bench-network
92+ healthcheck :
93+ test :
94+ - CMD
95+ - wait-for-it
96+ - ' redis-queue:6379'
97+ interval : 2s
98+ timeout : 10s
99+ retries : 30
100+ depends_on :
101+ configurator :
102+ condition : service_completed_successfully
103+ required : true
104+
105+ queue-short :
106+ << : *custom_image
107+ command :
108+ - bench
109+ - worker
110+ - --queue
111+ - short
112+ volumes :
113+ - sites:/home/frappe/frappe-bench/sites
114+ networks :
115+ - bench-network
116+ healthcheck :
117+ test :
118+ - CMD
119+ - wait-for-it
120+ - ' redis-queue:6379'
121+ interval : 2s
122+ timeout : 10s
123+ retries : 30
124+ depends_on :
125+ configurator :
126+ condition : service_completed_successfully
127+ required : true
128+
129+ scheduler :
130+ << : *custom_image
131+ healthcheck :
132+ test :
133+ - CMD
134+ - wait-for-it
135+ - ' redis-queue:6379'
136+ interval : 2s
137+ timeout : 10s
138+ retries : 30
139+ command :
140+ - bench
141+ - schedule
142+ depends_on :
143+ configurator :
144+ condition : service_completed_successfully
145+ required : true
146+ volumes :
147+ - sites:/home/frappe/frappe-bench/sites
148+ networks :
149+ - bench-network
150+
151+ websocket :
152+ << : *custom_image
153+ healthcheck :
154+ test :
155+ - CMD
156+ - wait-for-it
157+ - ' 0.0.0.0:9000'
158+ interval : 2s
159+ timeout : 10s
160+ retries : 30
161+ command :
162+ - node
163+ - /home/frappe/frappe-bench/apps/frappe/socketio.js
164+ depends_on :
165+ configurator :
166+ condition : service_completed_successfully
167+ required : true
168+ volumes :
169+ - sites:/home/frappe/frappe-bench/sites
170+ networks :
171+ - bench-network
172+
173+ configurator :
174+ << : *custom_image
175+ deploy :
176+ mode : replicated
177+ replicas : ${CONFIGURE:-0}
178+ restart_policy :
179+ condition : none
180+ entrypoint : ["bash", "-c"]
181+ command :
182+ - >
183+ [[ $${REGENERATE_APPS_TXT} == "1" ]] && ls -1 apps > sites/apps.txt;
184+ [[ -n `grep -hs ^ sites/common_site_config.json | jq -r ".db_host // empty"` ]] && exit 0;
185+ bench set-config -g db_host $$DB_HOST;
186+ bench set-config -gp db_port $$DB_PORT;
187+ bench set-config -g redis_cache "redis://$$REDIS_CACHE";
188+ bench set-config -g redis_queue "redis://$$REDIS_QUEUE";
189+ bench set-config -g redis_socketio "redis://$$REDIS_QUEUE";
190+ bench set-config -gp socketio_port $$SOCKETIO_PORT;
191+ environment :
192+ DB_HOST : db
193+ DB_PORT : " 3306"
194+ REDIS_CACHE : redis-cache:6379
195+ REDIS_QUEUE : redis-queue:6379
196+ SOCKETIO_PORT : " 9000"
197+ REGENERATE_APPS_TXT : " ${REGENERATE_APPS_TXT:-0}"
198+ volumes :
199+ - sites:/home/frappe/frappe-bench/sites
200+ networks :
201+ - bench-network
202+
203+ create-site :
204+ << : *custom_image
205+ deploy :
206+ mode : replicated
207+ replicas : ${CREATE_SITE:-0}
208+ restart_policy :
209+ condition : none
210+ entrypoint : ["bash", "-c"]
211+ command :
212+ - >
213+ wait-for-it -t 120 db:3306;
214+ wait-for-it -t 120 redis-cache:6379;
215+ wait-for-it -t 120 redis-queue:6379;
216+ export start=`date +%s`;
217+ until [[ -n `grep -hs ^ sites/common_site_config.json | jq -r ".db_host // empty"` ]] && \
218+ [[ -n `grep -hs ^ sites/common_site_config.json | jq -r ".redis_cache // empty"` ]] && \
219+ [[ -n `grep -hs ^ sites/common_site_config.json | jq -r ".redis_queue // empty"` ]];
220+ do
221+ echo "Waiting for sites/common_site_config.json to be created";
222+ sleep 5;
223+ if (( `date +%s`-start > 120 )); then
224+ echo "could not find sites/common_site_config.json with required keys";
225+ exit 1
226+ fi
227+ done;
228+ echo "sites/common_site_config.json found";
229+ [[ -d "sites/${SITE_NAME}" ]] && echo "${SITE_NAME} already exists" && exit 0;
230+ bench new-site --mariadb-user-host-login-scope='%' --admin-password=$${ADMIN_PASSWORD} --db-root-username=root --db-root-password=$${DB_ROOT_PASSWORD} $${INSTALL_APP_ARGS} $${SITE_NAME};
231+ volumes :
232+ - sites:/home/frappe/frappe-bench/sites
233+ environment :
234+ ADMIN_PASSWORD : ${ADMIN_PASSWORD}
235+ DB_ROOT_PASSWORD : ${DB_ROOT_PASSWORD}
236+ INSTALL_APP_ARGS : ${INSTALL_APP_ARGS}
237+ SITE_NAME : ${SITE_NAME}
238+ networks :
239+ - bench-network
240+
241+ migration :
242+ << : *custom_image
243+ deploy :
244+ mode : replicated
245+ replicas : ${MIGRATE:-0}
246+ restart_policy :
247+ condition : none
248+ entrypoint : ["bash", "-c"]
249+ command :
250+ - >
251+ curl -f http://${SITE_NAME}:8080/api/method/ping || echo "Site busy" && exit 0;
252+ bench --site all set-config -p maintenance_mode 1;
253+ bench --site all set-config -p pause_scheduler 1;
254+ bench --site all migrate;
255+ bench --site all set-config -p maintenance_mode 0;
256+ bench --site all set-config -p pause_scheduler 0;
257+ volumes :
258+ - sites:/home/frappe/frappe-bench/sites
259+ networks :
260+ - bench-network
261+
262+ db :
263+ image : mariadb:10.6
264+ deploy :
265+ restart_policy :
266+ condition : always
267+ healthcheck :
268+ test : mysqladmin ping -h localhost --password=${DB_ROOT_PASSWORD}
269+ interval : 1s
270+ retries : 20
271+ command :
272+ - --character-set-server=utf8mb4
273+ - --collation-server=utf8mb4_unicode_ci
274+ - --skip-character-set-client-handshake
275+ - --skip-innodb-read-only-compressed
276+ environment :
277+ - MYSQL_ROOT_PASSWORD=${DB_ROOT_PASSWORD}
278+ - MARIADB_ROOT_PASSWORD=${DB_ROOT_PASSWORD}
279+ volumes :
280+ - db-data:/var/lib/mysql
281+ networks :
282+ - bench-network
283+
284+ redis-cache :
285+ deploy :
286+ restart_policy :
287+ condition : always
288+ image : redis:6.2-alpine
289+ volumes :
290+ - redis-cache-data:/data
291+ networks :
292+ - bench-network
293+ healthcheck :
294+ test :
295+ - CMD
296+ - redis-cli
297+ - ping
298+ interval : 5s
299+ timeout : 5s
300+ retries : 3
301+
302+ redis-queue :
303+ deploy :
304+ restart_policy :
305+ condition : always
306+ image : redis:6.2-alpine
307+ volumes :
308+ - redis-queue-data:/data
309+ networks :
310+ - bench-network
311+ healthcheck :
312+ test :
313+ - CMD
314+ - redis-cli
315+ - ping
316+ interval : 5s
317+ timeout : 5s
318+ retries : 3
319+
320+ redis-socketio :
321+ deploy :
322+ restart_policy :
323+ condition : always
324+ image : redis:6.2-alpine
325+ volumes :
326+ - redis-socketio-data:/data
327+ networks :
328+ - bench-network
329+ healthcheck :
330+ test :
331+ - CMD
332+ - redis-cli
333+ - ping
334+ interval : 5s
335+ timeout : 5s
336+ retries : 3
337+
338+ volumes :
339+ db-data :
340+ redis-cache-data :
341+ redis-queue-data :
342+ redis-socketio-data :
343+ sites :
344+
345+ networks :
346+ bench-network:
0 commit comments