mirror of
https://github.com/frappe/frappe_docker.git
synced 2025-01-10 00:37:53 +00:00
Add configurator service to dynamically set common config
This commit is contained in:
parent
a1075c27c1
commit
9ab2547623
@ -90,14 +90,12 @@ USER frappe
|
|||||||
COPY pretend-bench.sh /usr/local/bin/bench
|
COPY pretend-bench.sh /usr/local/bin/bench
|
||||||
COPY push_backup.py /usr/local/bin/push-backup
|
COPY push_backup.py /usr/local/bin/push-backup
|
||||||
# healthcheck.sh used in helm chart
|
# 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
|
WORKDIR /home/frappe/frappe-bench/sites
|
||||||
|
|
||||||
VOLUME [ "/home/frappe/frappe-bench/sites", "/home/frappe/frappe-bench/logs" ]
|
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", "-" ]
|
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
21
build/worker/configure.sh
Executable 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 "$@"
|
@ -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 "$@"
|
|
42
compose.yaml
42
compose.yaml
@ -1,6 +1,7 @@
|
|||||||
services:
|
services:
|
||||||
backend:
|
configurator:
|
||||||
image: frappe/frappe-worker:${FRAPPE_VERSION}
|
image: frappe/frappe-worker:${FRAPPE_VERSION}
|
||||||
|
command: configure.sh
|
||||||
environment:
|
environment:
|
||||||
DB_HOST: db
|
DB_HOST: db
|
||||||
DB_PORT: 3306
|
DB_PORT: 3306
|
||||||
@ -10,11 +11,19 @@ services:
|
|||||||
SOCKETIO_PORT: 9000
|
SOCKETIO_PORT: 9000
|
||||||
volumes:
|
volumes:
|
||||||
- sites:/home/frappe/frappe-bench/sites
|
- sites:/home/frappe/frappe-bench/sites
|
||||||
- assets:/home/frappe/frappe-bench/sites/assets
|
|
||||||
depends_on:
|
depends_on:
|
||||||
db:
|
db:
|
||||||
condition: service_healthy
|
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:
|
db:
|
||||||
image: mariadb:10.6
|
image: mariadb:10.6
|
||||||
healthcheck:
|
healthcheck:
|
||||||
@ -29,18 +38,15 @@ services:
|
|||||||
environment:
|
environment:
|
||||||
MYSQL_ROOT_PASSWORD: ${DB_PASSWORD}
|
MYSQL_ROOT_PASSWORD: ${DB_PASSWORD}
|
||||||
volumes:
|
volumes:
|
||||||
- db:/var/lib/mysql
|
- db-data:/var/lib/mysql
|
||||||
|
|
||||||
redis:
|
redis:
|
||||||
image: redis:6.2-alpine
|
image: redis:6.2-alpine
|
||||||
volumes:
|
volumes:
|
||||||
- redis:/data
|
- redis-data:/data
|
||||||
|
|
||||||
frontend:
|
frontend:
|
||||||
image: frappe/frappe-nginx:${FRAPPE_VERSION}
|
image: frappe/frappe-nginx:${FRAPPE_VERSION}
|
||||||
depends_on:
|
|
||||||
- backend
|
|
||||||
- websocket
|
|
||||||
environment:
|
environment:
|
||||||
BACKEND: backend:8000
|
BACKEND: backend:8000
|
||||||
SOCKETIO: websocket:9000
|
SOCKETIO: websocket:9000
|
||||||
@ -48,6 +54,9 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
- sites:/usr/share/nginx/html/sites
|
- sites:/usr/share/nginx/html/sites
|
||||||
- assets:/usr/share/nginx/html/assets
|
- assets:/usr/share/nginx/html/assets
|
||||||
|
depends_on:
|
||||||
|
- backend
|
||||||
|
- websocket
|
||||||
labels:
|
labels:
|
||||||
- traefik.enable=true
|
- traefik.enable=true
|
||||||
- traefik.http.services.frontend.loadbalancer.server.port=80
|
- traefik.http.services.frontend.loadbalancer.server.port=80
|
||||||
@ -68,46 +77,41 @@ services:
|
|||||||
|
|
||||||
websocket:
|
websocket:
|
||||||
image: frappe/frappe-socketio:${FRAPPE_VERSION}
|
image: frappe/frappe-socketio:${FRAPPE_VERSION}
|
||||||
depends_on:
|
|
||||||
- backend
|
|
||||||
volumes:
|
volumes:
|
||||||
- sites:/home/frappe/frappe-bench/sites
|
- sites:/home/frappe/frappe-bench/sites
|
||||||
|
depends_on: *depends_on_configurator
|
||||||
|
|
||||||
queue-short:
|
queue-short:
|
||||||
image: frappe/frappe-worker:${FRAPPE_VERSION}
|
image: frappe/frappe-worker:${FRAPPE_VERSION}
|
||||||
command: bench worker --queue short
|
command: bench worker --queue short
|
||||||
volumes:
|
volumes:
|
||||||
- sites:/home/frappe/frappe-bench/sites
|
- sites:/home/frappe/frappe-bench/sites
|
||||||
depends_on:
|
depends_on: *depends_on_configurator
|
||||||
- backend
|
|
||||||
|
|
||||||
queue-default:
|
queue-default:
|
||||||
image: frappe/frappe-worker:${FRAPPE_VERSION}
|
image: frappe/frappe-worker:${FRAPPE_VERSION}
|
||||||
command: bench worker --queue default
|
command: bench worker --queue default
|
||||||
volumes:
|
volumes:
|
||||||
- sites:/home/frappe/frappe-bench/sites
|
- sites:/home/frappe/frappe-bench/sites
|
||||||
depends_on:
|
depends_on: *depends_on_configurator
|
||||||
- backend
|
|
||||||
|
|
||||||
queue-long:
|
queue-long:
|
||||||
image: frappe/frappe-worker:${FRAPPE_VERSION}
|
image: frappe/frappe-worker:${FRAPPE_VERSION}
|
||||||
command: bench worker --queue long
|
command: bench worker --queue long
|
||||||
volumes:
|
volumes:
|
||||||
- sites:/home/frappe/frappe-bench/sites
|
- sites:/home/frappe/frappe-bench/sites
|
||||||
depends_on:
|
depends_on: *depends_on_configurator
|
||||||
- backend
|
|
||||||
|
|
||||||
scheduler:
|
scheduler:
|
||||||
image: frappe/frappe-worker:${FRAPPE_VERSION}
|
image: frappe/frappe-worker:${FRAPPE_VERSION}
|
||||||
command: bench schedule
|
command: bench schedule
|
||||||
volumes:
|
volumes:
|
||||||
- sites:/home/frappe/frappe-bench/sites
|
- sites:/home/frappe/frappe-bench/sites
|
||||||
depends_on:
|
depends_on: *depends_on_configurator
|
||||||
- backend
|
|
||||||
|
|
||||||
# ERPNext requires local assets access (Frappe does not)
|
# ERPNext requires local assets access (Frappe does not)
|
||||||
volumes:
|
volumes:
|
||||||
sites:
|
sites:
|
||||||
assets:
|
assets:
|
||||||
db:
|
db-data:
|
||||||
redis:
|
redis-data:
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
services:
|
services:
|
||||||
|
configurator:
|
||||||
|
image: frappe/erpnext-worker:${ERPNEXT_VERSION}
|
||||||
|
|
||||||
backend:
|
backend:
|
||||||
image: frappe/erpnext-worker:${ERPNEXT_VERSION}
|
image: frappe/erpnext-worker:${ERPNEXT_VERSION}
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ services:
|
|||||||
ports:
|
ports:
|
||||||
- 443:443
|
- 443:443
|
||||||
volumes:
|
volumes:
|
||||||
- cert:/letsencrypt
|
- cert-data:/letsencrypt
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
cert:
|
cert-data:
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
services:
|
services:
|
||||||
backend:
|
configurator:
|
||||||
image: frappe/frappe-worker:${FRAPPE_VERSION}
|
|
||||||
environment:
|
environment:
|
||||||
DB_HOST: db
|
|
||||||
DB_PORT: 5432
|
DB_PORT: 5432
|
||||||
depends_on:
|
depends_on:
|
||||||
- db
|
- db
|
||||||
@ -17,4 +15,4 @@ services:
|
|||||||
environment:
|
environment:
|
||||||
POSTGRES_PASSWORD: ${DB_PASSWORD}
|
POSTGRES_PASSWORD: ${DB_PASSWORD}
|
||||||
volumes:
|
volumes:
|
||||||
- db:/var/lib/postgresql
|
- db-data:/var/lib/postgresql
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
services:
|
services:
|
||||||
|
configurator:
|
||||||
|
image: localhost:5000/frappe/erpnext-worker:${ERPNEXT_VERSION}
|
||||||
|
|
||||||
backend:
|
backend:
|
||||||
image: localhost:5000/frappe/erpnext-worker:${ERPNEXT_VERSION}
|
image: localhost:5000/frappe/erpnext-worker:${ERPNEXT_VERSION}
|
||||||
|
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
services:
|
services:
|
||||||
|
configurator:
|
||||||
|
image: localhost:5000/frappe/frappe-worker:${FRAPPE_VERSION}
|
||||||
|
|
||||||
backend:
|
backend:
|
||||||
image: localhost:5000/frappe/frappe-worker:${FRAPPE_VERSION}
|
image: localhost:5000/frappe/frappe-worker:${FRAPPE_VERSION}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user