22# new image: https://hub.docker.com/r/frappe/erpnext/tags
33# docs: https://github.com/frappe/frappe_docker/blob/main/pwd.yml
44
5- version : ' 3.8'
6-
75services :
86 backend :
97 image : $W9_REPO:$W9_VERSION
108 container_name : $W9_ID-backend
9+ depends_on :
10+ create-site :
11+ condition : service_completed_successfully
1112 restart : unless-stopped
1213 volumes :
14+ - apps:/home/frappe/frappe-bench/apps
15+ - env:/home/frappe/frappe-bench/env
1316 - sites:/home/frappe/frappe-bench/sites
1417 - logs:/home/frappe/frappe-bench/logs
1518
@@ -23,20 +26,16 @@ services:
2326 # add redis_socketio for backward compatibility
2427 command :
2528 - >
26- ls -1 apps > sites/apps.txt;
27- bench set-config -g db_host $$DB_HOST;
28- bench set-config -gp db_port $$DB_PORT;
29- bench set-config -g redis_cache "redis://$$REDIS_CACHE";
30- bench set-config -g redis_queue "redis://$$REDIS_QUEUE";
31- bench set-config -g redis_socketio "redis://$$REDIS_QUEUE";
32- bench set-config -gp socketio_port $$SOCKETIO_PORT;
29+ 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_QUEUE"; bench set-config -gp socketio_port $$SOCKETIO_PORT;
3330 environment :
3431 DB_HOST : $W9_ID-mariadb
3532 DB_PORT : " 3306"
3633 REDIS_CACHE : $W9_ID-redis-cache:6379
3734 REDIS_QUEUE : $W9_ID-redis-queue:6379
3835 SOCKETIO_PORT : " 9000"
3936 volumes :
37+ - apps:/home/frappe/frappe-bench/apps
38+ - env:/home/frappe/frappe-bench/env
4039 - sites:/home/frappe/frappe-bench/sites
4140 - logs:/home/frappe/frappe-bench/logs
4241
@@ -45,18 +44,16 @@ services:
4544 container_name : $W9_ID-create-site
4645 restart : none
4746 volumes :
47+ - apps:/home/frappe/frappe-bench/apps
48+ - env:/home/frappe/frappe-bench/env
4849 - sites:/home/frappe/frappe-bench/sites
4950 - logs:/home/frappe/frappe-bench/logs
5051 entrypoint :
5152 - bash
5253 - -c
5354 command :
5455 - >
55- wait-for-it -t 120 $W9_ID-mariadb:3306;
56- wait-for-it -t 120 $W9_ID-redis-cache:6379;
57- wait-for-it -t 120 $W9_ID-redis-queue:6379;
58- export start=`date +%s`;
59- until [[ -n `grep -hs ^ sites/common_site_config.json | jq -r ".db_host // empty"` ]] && \
56+ set -e; wait-for-it -t 120 $W9_ID-mariadb:3306; wait-for-it -t 120 $W9_ID-redis-cache:6379; wait-for-it -t 120 $W9_ID-redis-queue:6379; export start=`date +%s`; until [[ -n `grep -hs ^ sites/common_site_config.json | jq -r ".db_host // empty"` ]] && \
6057 [[ -n `grep -hs ^ sites/common_site_config.json | jq -r ".redis_cache // empty"` ]] && \
6158 [[ -n `grep -hs ^ sites/common_site_config.json | jq -r ".redis_queue // empty"` ]];
6259 do
@@ -66,9 +63,24 @@ services:
6663 echo "could not find sites/common_site_config.json with required keys";
6764 exit 1
6865 fi
69- done;
70- echo "sites/common_site_config.json found";
71- bench new-site --no-mariadb-socket --admin-password=$W9_LOGIN_PASSWORD --db-root-password=$W9_LOGIN_PASSWORD --install-app erpnext --set-default frontend;
66+ done; echo "sites/common_site_config.json found"; if [ ! -d sites/frontend ]; then
67+ bench new-site --mariadb-user-host-login-scope='%' --admin-password=$W9_LOGIN_PASSWORD --db-root-username=root --db-root-password=$W9_LOGIN_PASSWORD --install-app erpnext --set-default frontend;
68+ else
69+ echo "Site frontend already exists, skip new-site";
70+ fi; if [ ! -d apps/hrms ]; then
71+ bench get-app --branch $W9_HRMS_BRANCH hrms;
72+ fi; bench pip install -e apps/hrms; ls -1 apps > sites/apps.txt; if ! bench --site frontend list-apps | grep -qx hrms; then
73+ bench --site frontend install-app hrms;
74+ else
75+ echo "HRMS already installed on frontend";
76+ fi; mkdir -p sites/assets; rm -rf sites/assets/hrms; cp -a /home/frappe/frappe-bench/apps/hrms/hrms/public sites/assets/hrms; if command -v node >/dev/null 2>&1; then
77+ bench build --app hrms;
78+ else
79+ echo "node not found, skip bench build --app hrms";
80+ fi; if [ ! -f sites/assets/hrms/images/frappe-hr-logo.svg ]; then
81+ echo "ERROR: HRMS asset missing after build: sites/assets/hrms/images/frappe-hr-logo.svg";
82+ exit 1;
83+ fi; bench --site frontend migrate; bench --site frontend clear-cache; bench --site frontend clear-website-cache;
7284
7385 mariadb :
7486 image : mariadb:$W9_DB_VERSION
@@ -92,9 +104,12 @@ services:
92104 image : $W9_REPO:$W9_VERSION
93105 container_name : $W9_ID
94106 depends_on :
95- - websocket
107+ create-site :
108+ condition : service_completed_successfully
109+ websocket :
110+ condition : service_started
96111 restart : unless-stopped
97- env_file :
112+ env_file :
98113 - .env
99114 command :
100115 - nginx-entrypoint.sh
@@ -108,6 +123,8 @@ services:
108123 PROXY_READ_TIMEOUT : 120
109124 CLIENT_MAX_BODY_SIZE : 50m
110125 volumes :
126+ - apps:/home/frappe/frappe-bench/apps
127+ - env:/home/frappe/frappe-bench/env
111128 - sites:/home/frappe/frappe-bench/sites
112129 - logs:/home/frappe/frappe-bench/logs
113130 ports :
@@ -116,26 +133,36 @@ services:
116133 queue-long :
117134 image : $W9_REPO:$W9_VERSION
118135 container_name : $W9_ID-queue-long
136+ depends_on :
137+ create-site :
138+ condition : service_completed_successfully
119139 restart : unless-stopped
120140 command :
121141 - bench
122142 - worker
123143 - --queue
124144 - long,default,short
125145 volumes :
146+ - apps:/home/frappe/frappe-bench/apps
147+ - env:/home/frappe/frappe-bench/env
126148 - sites:/home/frappe/frappe-bench/sites
127149 - logs:/home/frappe/frappe-bench/logs
128150
129151 queue-short :
130152 image : $W9_REPO:$W9_VERSION
131153 container_name : $W9_ID-queue-short
154+ depends_on :
155+ create-site :
156+ condition : service_completed_successfully
132157 restart : unless-stopped
133158 command :
134159 - bench
135160 - worker
136161 - --queue
137162 - short,default
138163 volumes :
164+ - apps:/home/frappe/frappe-bench/apps
165+ - env:/home/frappe/frappe-bench/env
139166 - sites:/home/frappe/frappe-bench/sites
140167 - logs:/home/frappe/frappe-bench/logs
141168
@@ -156,32 +183,45 @@ services:
156183 scheduler :
157184 image : $W9_REPO:$W9_VERSION
158185 container_name : $W9_ID-scheduler
186+ depends_on :
187+ create-site :
188+ condition : service_completed_successfully
159189 restart : unless-stopped
160190 command :
161191 - bench
162192 - schedule
163193 volumes :
194+ - apps:/home/frappe/frappe-bench/apps
195+ - env:/home/frappe/frappe-bench/env
164196 - sites:/home/frappe/frappe-bench/sites
165197 - logs:/home/frappe/frappe-bench/logs
166198
167199 websocket :
168200 image : $W9_REPO:$W9_VERSION
169201 container_name : $W9_ID-websocket
202+ depends_on :
203+ create-site :
204+ condition : service_completed_successfully
170205 restart : unless-stopped
171206 command :
172207 - node
173208 - /home/frappe/frappe-bench/apps/frappe/socketio.js
174209 volumes :
210+ - apps:/home/frappe/frappe-bench/apps
211+ - env:/home/frappe/frappe-bench/env
175212 - sites:/home/frappe/frappe-bench/sites
176213 - logs:/home/frappe/frappe-bench/logs
177214
178215volumes :
216+ apps :
217+ env :
179218 db-data :
180219 redis-queue-data :
181220 redis-cache-data :
182221 sites :
183222 logs :
184223
224+
185225networks :
186226 default :
187227 name : $W9_NETWORK
0 commit comments