2
0
mirror of https://github.com/frappe/frappe_docker.git synced 2025-01-09 08:30:35 +00:00

Add configurator service to dynamically set common config

This commit is contained in:
Lev Vereshchagin 2021-12-15 12:41:35 +03:00
parent a1075c27c1
commit 9ab2547623
9 changed files with 58 additions and 52 deletions

View File

@ -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", "-" ]

21
build/worker/configure.sh Executable file
View File

@ -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 "$@"

View File

@ -1,24 +0,0 @@
#!/bin/bash
set -e
function create_common_site_config() {
if [[ ! -f common_site_config.json ]]; then
config=$(
cat <<EOF
{
"db_host": "${DB_HOST}",
"db_port": ${DB_PORT},
"redis_cache": "redis://${REDIS_CACHE}",
"redis_queue": "redis://${REDIS_QUEUE}",
"redis_socketio": "redis://${REDIS_SOCKETIO}",
"socketio_port": ${SOCKETIO_PORT}
}
EOF
)
echo "$config" >/home/frappe/frappe-bench/sites/common_site_config.json
fi
}
create_common_site_config
exec "$@"

View File

@ -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:

View File

@ -1,4 +1,7 @@
services:
configurator:
image: frappe/erpnext-worker:${ERPNEXT_VERSION}
backend:
image: frappe/erpnext-worker:${ERPNEXT_VERSION}

View File

@ -21,7 +21,7 @@ services:
ports:
- 443:443
volumes:
- cert:/letsencrypt
- cert-data:/letsencrypt
volumes:
cert:
cert-data:

View File

@ -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

View File

@ -1,4 +1,7 @@
services:
configurator:
image: localhost:5000/frappe/erpnext-worker:${ERPNEXT_VERSION}
backend:
image: localhost:5000/frappe/erpnext-worker:${ERPNEXT_VERSION}

View File

@ -1,4 +1,7 @@
services:
configurator:
image: localhost:5000/frappe/frappe-worker:${FRAPPE_VERSION}
backend:
image: localhost:5000/frappe/frappe-worker:${FRAPPE_VERSION}