diff --git a/build/worker/Dockerfile b/build/worker/Dockerfile index cc6626dd..bf33abe2 100644 --- a/build/worker/Dockerfile +++ b/build/worker/Dockerfile @@ -90,14 +90,12 @@ USER frappe COPY pretend-bench.sh /usr/local/bin/bench COPY push_backup.py /usr/local/bin/push-backup # healthcheck.sh used in helm chart -COPY entrypoint.sh patched_bench_helper.py healthcheck.sh /usr/local/bin/ +COPY configure.sh patched_bench_helper.py healthcheck.sh /usr/local/bin/ WORKDIR /home/frappe/frappe-bench/sites VOLUME [ "/home/frappe/frappe-bench/sites", "/home/frappe/frappe-bench/logs" ] -ENTRYPOINT [ "entrypoint.sh" ] - CMD [ "/home/frappe/frappe-bench/env/bin/gunicorn", "-b", "0.0.0.0:8000", "frappe.app:application", "--access-logfile", "-" ] diff --git a/build/worker/configure.sh b/build/worker/configure.sh new file mode 100755 index 00000000..dadef1f6 --- /dev/null +++ b/build/worker/configure.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +set -e +set -x + +CUR_DIR="$(pwd)" +cd /home/frappe/frappe-bench/sites + +if [[ ! -f common_site_config.json ]]; then + echo "{}" >common_site_config.json +fi + +bench set-config --global --parse socketio_port "${SOCKETIO_PORT}" +bench set-config --global db_host "${DB_HOST}" +bench set-config --global --parse db_port "${DB_PORT}" +bench set-config --global redis_cache "redis://${REDIS_CACHE}" +bench set-config --global redis_queue "redis://${REDIS_QUEUE}" +bench set-config --global redis_socketio "redis://${REDIS_SOCKETIO}" + +cd "$CUR_DIR" +exec "$@" diff --git a/build/worker/entrypoint.sh b/build/worker/entrypoint.sh deleted file mode 100755 index ba110a4f..00000000 --- a/build/worker/entrypoint.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -set -e - -function create_common_site_config() { - if [[ ! -f common_site_config.json ]]; then - config=$( - cat </home/frappe/frappe-bench/sites/common_site_config.json - fi -} - -create_common_site_config -exec "$@" diff --git a/compose.yaml b/compose.yaml index 1bad8e4f..6145bf41 100644 --- a/compose.yaml +++ b/compose.yaml @@ -1,6 +1,7 @@ services: - backend: + configurator: image: frappe/frappe-worker:${FRAPPE_VERSION} + command: configure.sh environment: DB_HOST: db DB_PORT: 3306 @@ -10,11 +11,19 @@ services: SOCKETIO_PORT: 9000 volumes: - sites:/home/frappe/frappe-bench/sites - - assets:/home/frappe/frappe-bench/sites/assets depends_on: db: condition: service_healthy + backend: + image: frappe/frappe-worker:${FRAPPE_VERSION} + volumes: + - sites:/home/frappe/frappe-bench/sites + - assets:/home/frappe/frappe-bench/sites/assets + depends_on: &depends_on_configurator + configurator: + condition: service_completed_successfully + db: image: mariadb:10.6 healthcheck: @@ -29,18 +38,15 @@ services: environment: MYSQL_ROOT_PASSWORD: ${DB_PASSWORD} volumes: - - db:/var/lib/mysql + - db-data:/var/lib/mysql redis: image: redis:6.2-alpine volumes: - - redis:/data + - redis-data:/data frontend: image: frappe/frappe-nginx:${FRAPPE_VERSION} - depends_on: - - backend - - websocket environment: BACKEND: backend:8000 SOCKETIO: websocket:9000 @@ -48,6 +54,9 @@ services: volumes: - sites:/usr/share/nginx/html/sites - assets:/usr/share/nginx/html/assets + depends_on: + - backend + - websocket labels: - traefik.enable=true - traefik.http.services.frontend.loadbalancer.server.port=80 @@ -68,46 +77,41 @@ services: websocket: image: frappe/frappe-socketio:${FRAPPE_VERSION} - depends_on: - - backend volumes: - sites:/home/frappe/frappe-bench/sites + depends_on: *depends_on_configurator queue-short: image: frappe/frappe-worker:${FRAPPE_VERSION} command: bench worker --queue short volumes: - sites:/home/frappe/frappe-bench/sites - depends_on: - - backend + depends_on: *depends_on_configurator queue-default: image: frappe/frappe-worker:${FRAPPE_VERSION} command: bench worker --queue default volumes: - sites:/home/frappe/frappe-bench/sites - depends_on: - - backend + depends_on: *depends_on_configurator queue-long: image: frappe/frappe-worker:${FRAPPE_VERSION} command: bench worker --queue long volumes: - sites:/home/frappe/frappe-bench/sites - depends_on: - - backend + depends_on: *depends_on_configurator scheduler: image: frappe/frappe-worker:${FRAPPE_VERSION} command: bench schedule volumes: - sites:/home/frappe/frappe-bench/sites - depends_on: - - backend + depends_on: *depends_on_configurator # ERPNext requires local assets access (Frappe does not) volumes: sites: assets: - db: - redis: + db-data: + redis-data: diff --git a/overrides/compose.erpnext.yaml b/overrides/compose.erpnext.yaml index 03042a36..4ddc43f7 100644 --- a/overrides/compose.erpnext.yaml +++ b/overrides/compose.erpnext.yaml @@ -1,4 +1,7 @@ services: + configurator: + image: frappe/erpnext-worker:${ERPNEXT_VERSION} + backend: image: frappe/erpnext-worker:${ERPNEXT_VERSION} diff --git a/overrides/compose.https.yaml b/overrides/compose.https.yaml index e5801a12..ee69a7c6 100644 --- a/overrides/compose.https.yaml +++ b/overrides/compose.https.yaml @@ -21,7 +21,7 @@ services: ports: - 443:443 volumes: - - cert:/letsencrypt + - cert-data:/letsencrypt volumes: - cert: + cert-data: diff --git a/overrides/compose.postgres.yaml b/overrides/compose.postgres.yaml index 5f1e445c..268c7de2 100644 --- a/overrides/compose.postgres.yaml +++ b/overrides/compose.postgres.yaml @@ -1,8 +1,6 @@ services: - backend: - image: frappe/frappe-worker:${FRAPPE_VERSION} + configurator: environment: - DB_HOST: db DB_PORT: 5432 depends_on: - db @@ -17,4 +15,4 @@ services: environment: POSTGRES_PASSWORD: ${DB_PASSWORD} volumes: - - db:/var/lib/postgresql + - db-data:/var/lib/postgresql diff --git a/tests/compose.ci-erpnext.yaml b/tests/compose.ci-erpnext.yaml index c1818c1d..c767b9da 100644 --- a/tests/compose.ci-erpnext.yaml +++ b/tests/compose.ci-erpnext.yaml @@ -1,4 +1,7 @@ services: + configurator: + image: localhost:5000/frappe/erpnext-worker:${ERPNEXT_VERSION} + backend: image: localhost:5000/frappe/erpnext-worker:${ERPNEXT_VERSION} diff --git a/tests/compose.ci.yaml b/tests/compose.ci.yaml index 3e3ba0e4..c7e168f9 100644 --- a/tests/compose.ci.yaml +++ b/tests/compose.ci.yaml @@ -1,4 +1,7 @@ services: + configurator: + image: localhost:5000/frappe/frappe-worker:${FRAPPE_VERSION} + backend: image: localhost:5000/frappe/frappe-worker:${FRAPPE_VERSION}