feat: add adapted ERPNext v16 docker-compose for Coolify deployment

This commit is contained in:
Claude 2026-07-20 23:22:52 +02:00
commit 58953df167
3 changed files with 206 additions and 0 deletions

2
.env.example Normal file
View file

@ -0,0 +1,2 @@
MARIADB_ROOT_PASSWORD=
ADMIN_PASSWORD=

18
README.md Normal file
View file

@ -0,0 +1,18 @@
# erpnext-deploy
Docker Compose pentru Frappe/ERPNext v16.28.0, adaptat dupa `frappe_docker/pwd.yml` oficial pentru deployment persistent prin Coolify (nu doar trial):
- `deploy.restart_policy` (ignorat de docker compose in mod non-swarm) inlocuit cu `restart:` explicit
- parole (MariaDB root, admin site) prin variabile de mediu, setate ca Environment Variables in Coolify — nu sunt hardcodate in acest fisier
- `create-site` e idempotent (verifica daca site-ul exista deja inainte sa incerce sa-l recreeze la un redeploy)
- portul frontend e mapat pe `8081` (portul 8080 e deja folosit de dashboard-ul Traefik al Coolify)
## Servicii
`backend` (Frappe/ERPNext app server), `db` (MariaDB 11.8), `frontend` (nginx), `queue-long`/`queue-short` (job workers), `scheduler`, `websocket` (realtime), `redis-cache`/`redis-queue`. `configurator` si `create-site` sunt containere one-shot (ruleaza o data la primul deploy).
## Deploy
In Coolify: Application → Docker Compose → acest repo, branch `main`, apoi seteaza env vars `MARIADB_ROOT_PASSWORD` si `ADMIN_PASSWORD`.
Dupa primul deploy reusit, login la `http://<host>:8081` cu user `Administrator` si parola din `ADMIN_PASSWORD`.

186
docker-compose.yml Normal file
View file

@ -0,0 +1,186 @@
services:
backend:
image: frappe/erpnext:v16.28.0
restart: unless-stopped
volumes:
- sites:/home/frappe/frappe-bench/sites
- logs:/home/frappe/frappe-bench/logs
environment:
DB_HOST: db
DB_PORT: "3306"
MYSQL_ROOT_PASSWORD: ${MARIADB_ROOT_PASSWORD}
MARIADB_ROOT_PASSWORD: ${MARIADB_ROOT_PASSWORD}
configurator:
image: frappe/erpnext:v16.28.0
restart: "no"
entrypoint:
- bash
- -c
command:
- >
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;
environment:
DB_HOST: db
DB_PORT: "3306"
REDIS_CACHE: redis-cache:6379
REDIS_QUEUE: redis-queue:6379
SOCKETIO_PORT: "9000"
volumes:
- sites:/home/frappe/frappe-bench/sites
- logs:/home/frappe/frappe-bench/logs
depends_on:
db:
condition: service_healthy
create-site:
image: frappe/erpnext:v16.28.0
restart: "no"
volumes:
- sites:/home/frappe/frappe-bench/sites
- logs:/home/frappe/frappe-bench/logs
entrypoint:
- bash
- -c
environment:
MARIADB_ROOT_PASSWORD: ${MARIADB_ROOT_PASSWORD}
ADMIN_PASSWORD: ${ADMIN_PASSWORD}
command:
- >
wait-for-it -t 120 db:3306;
wait-for-it -t 120 redis-cache:6379;
wait-for-it -t 120 redis-queue:6379;
export start=`date +%s`;
until [[ -n `grep -hs ^ sites/common_site_config.json | jq -r ".db_host // empty"` ]] && \
[[ -n `grep -hs ^ sites/common_site_config.json | jq -r ".redis_cache // empty"` ]] && \
[[ -n `grep -hs ^ sites/common_site_config.json | jq -r ".redis_queue // empty"` ]];
do
echo "Waiting for sites/common_site_config.json to be created";
sleep 5;
if (( `date +%s`-start > 120 )); then
echo "could not find sites/common_site_config.json with required keys";
exit 1
fi
done;
echo "sites/common_site_config.json found";
[[ -f sites/frontend/site_config.json ]] && echo "site already exists, skipping" && exit 0;
bench new-site --mariadb-user-host-login-scope='%' --admin-password=$$ADMIN_PASSWORD --db-root-username=root --db-root-password=$$MARIADB_ROOT_PASSWORD --install-app erpnext --set-default frontend;
depends_on:
configurator:
condition: service_completed_successfully
db:
image: mariadb:11.8
restart: unless-stopped
healthcheck:
test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"]
start_period: 5s
interval: 5s
timeout: 5s
retries: 5
command:
- --character-set-server=utf8mb4
- --collation-server=utf8mb4_unicode_ci
- --skip-character-set-client-handshake
environment:
MYSQL_ROOT_PASSWORD: ${MARIADB_ROOT_PASSWORD}
MARIADB_ROOT_PASSWORD: ${MARIADB_ROOT_PASSWORD}
volumes:
- db-data:/var/lib/mysql
frontend:
image: frappe/erpnext:v16.28.0
restart: unless-stopped
depends_on:
- websocket
command:
- nginx-entrypoint.sh
environment:
BACKEND: backend:8000
FRAPPE_SITE_NAME_HEADER: frontend
SOCKETIO: websocket:9000
UPSTREAM_REAL_IP_ADDRESS: 127.0.0.1
UPSTREAM_REAL_IP_HEADER: X-Forwarded-For
UPSTREAM_REAL_IP_RECURSIVE: "off"
PROXY_READ_TIMEOUT: 120
CLIENT_MAX_BODY_SIZE: 50m
volumes:
- sites:/home/frappe/frappe-bench/sites
- logs:/home/frappe/frappe-bench/logs
ports:
- "8081:8080"
queue-long:
image: frappe/erpnext:v16.28.0
restart: unless-stopped
command:
- bench
- worker
- --queue
- long,default,short
volumes:
- sites:/home/frappe/frappe-bench/sites
- logs:/home/frappe/frappe-bench/logs
environment:
FRAPPE_REDIS_CACHE: redis://redis-cache:6379
FRAPPE_REDIS_QUEUE: redis://redis-queue:6379
queue-short:
image: frappe/erpnext:v16.28.0
restart: unless-stopped
command:
- bench
- worker
- --queue
- short,default
volumes:
- sites:/home/frappe/frappe-bench/sites
- logs:/home/frappe/frappe-bench/logs
environment:
FRAPPE_REDIS_CACHE: redis://redis-cache:6379
FRAPPE_REDIS_QUEUE: redis://redis-queue:6379
redis-queue:
image: redis:6.2-alpine
restart: unless-stopped
volumes:
- redis-queue-data:/data
redis-cache:
image: redis:6.2-alpine
restart: unless-stopped
scheduler:
image: frappe/erpnext:v16.28.0
restart: unless-stopped
command:
- bench
- schedule
volumes:
- sites:/home/frappe/frappe-bench/sites
- logs:/home/frappe/frappe-bench/logs
websocket:
image: frappe/erpnext:v16.28.0
restart: unless-stopped
command:
- node
- /home/frappe/frappe-bench/apps/frappe/socketio.js
environment:
FRAPPE_REDIS_CACHE: redis://redis-cache:6379
FRAPPE_REDIS_QUEUE: redis://redis-queue:6379
volumes:
- sites:/home/frappe/frappe-bench/sites
- logs:/home/frappe/frappe-bench/logs
volumes:
db-data:
redis-queue-data:
sites:
logs: