Fixed build and env

This commit is contained in:
Christian Anetzberger committed 2026-10-31 14:13:55 +01:00
1 parent 967299888a
commit b26b8f22a4
4 files changed
+488 -30

No files matched your search

Regular → Executable
+86 -30
View File
@@ -2,21 +2,38 @@
#!/usr/bin/env bash
set -euo pipefail
# --------------------------------------------------
# Configuration
# --------------------------------------------------
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_DIR="${ROOT_DIR}/frappe_repo"
FRAPPE_REPO="${FRAPPE_DOCKER_DIR:-${ROOT_DIR}/../frappe_docker}"
REGISTRY_IMAGE="git.prothmann.com/christian/erpnexthp"
BUILD_IMAGE="${REGISTRY_IMAGE}:build-local"
cd "$REPO_DIR"
if [[ ! -f "${FRAPPE_REPO}/images/layered/Containerfile" ]]; then
echo "ERROR: frappe_docker repository not found."
exit 1
fi
if [[ ! -f "${ROOT_DIR}/docker-compose.override.yml" ]]; then
echo "ERROR: Missing docker-compose.override.yml"
exit 1
fi
cd "$FRAPPE_REPO"
APPS_FILE="$(mktemp)"
COMPOSE_ENV_FILE="$(mktemp)"
trap 'rm -f "$APPS_FILE" "$COMPOSE_ENV_FILE"' EXIT
# --------------------------------------------------
# 1. Define applications
# --------------------------------------------------
APPS_FILE="$(mktemp)"
trap 'rm -f "$APPS_FILE"' EXIT
cat > "$APPS_FILE" <<'JSON'
[
{
@@ -57,7 +74,7 @@ docker buildx build \
.
# --------------------------------------------------
# 3. Read ERPNext version from built image
# 3. Detect actual ERPNext version
# --------------------------------------------------
ERP_VERSION="$(
@@ -69,7 +86,7 @@ ERP_VERSION="$(
| awk -F '"' '/^__version__ = / {print $2; exit}'
)"
if [[ ! "$ERP_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
if [[ ! "$ERP_VERSION" =~ ^16\.[0-9]+\.[0-9]+$ ]]; then
echo "ERROR: Could not determine ERPNext version."
exit 1
fi
@@ -78,40 +95,79 @@ FINAL_IMAGE="${REGISTRY_IMAGE}:${ERP_VERSION}"
echo "Detected ERPNext version: ${ERP_VERSION}"
docker tag "${BUILD_IMAGE}" "${FINAL_IMAGE}"
# --------------------------------------------------
# 4. Tag and push to Gitea
# 4. Prepare temporary Compose environment
# --------------------------------------------------
docker tag "${BUILD_IMAGE}" "${FINAL_IMAGE}"
# Dummy database password is used only during
# generation. The production override reads the
# real password from hyp1's .env file.
{
printf 'ERPNEXT_VERSION=%s\n' "$ERP_VERSION"
printf 'CUSTOM_IMAGE=%s\n' "$REGISTRY_IMAGE"
printf 'CUSTOM_TAG=%s\n' "$ERP_VERSION"
cat <<'ENV'
DB_PASSWORD=COMPOSE_TEMPLATE_ONLY
PULL_POLICY=always
RESTART_POLICY=unless-stopped
SITES_RULE=Host(`erp16.prothmann.com`)
ENV
} > "$COMPOSE_ENV_FILE"
# --------------------------------------------------
# 5. Generate official production Compose
# --------------------------------------------------
echo "Generating production Docker Compose..."
docker compose \
--env-file "$COMPOSE_ENV_FILE" \
--project-name erpnext-16 \
-f compose.yaml \
-f overrides/compose.mariadb.yaml \
-f overrides/compose.redis.yaml \
config > "${ROOT_DIR}/docker-compose.yml"
# --------------------------------------------------
# 6. Validate final configuration
# --------------------------------------------------
echo "Validating Docker Compose..."
docker compose \
--env-file "$COMPOSE_ENV_FILE" \
--project-name erpnext-16 \
-f "${ROOT_DIR}/docker-compose.yml" \
-f "${ROOT_DIR}/docker-compose.override.yml" \
config --quiet
echo "Docker Compose validation successful."
# --------------------------------------------------
# 7. Push image to Gitea
# --------------------------------------------------
echo "Publishing ${FINAL_IMAGE}..."
docker push "${FINAL_IMAGE}"
# --------------------------------------------------
# 5. Generate official Compose for hyp1
# 8. Summary
# --------------------------------------------------
echo "Generating production Docker Compose..."
docker compose \
--project-name erpnext-16 \
-f compose.yaml \
-f overrides/compose.mariadb.yaml \
-f overrides/compose.redis.yaml \
config --no-interpolate \
> "${ROOT_DIR}/docker-compose.yml"
# Ensure the version stays configurable
if ! grep -q 'CUSTOM_IMAGE' "${ROOT_DIR}/docker-compose.yml"; then
echo "ERROR: Image variables were not preserved."
exit 1
fi
echo ""
echo "Build completed successfully."
echo "Image: ${FINAL_IMAGE}"
echo "Compose: ${ROOT_DIR}/docker-compose.yml"
echo "============================================"
echo " ERPNext production build completed"
echo "============================================"
echo ""
echo "ERPNext version: ${ERP_VERSION}"
echo "Docker image: ${FINAL_IMAGE}"
echo "Compose file: ${ROOT_DIR}/docker-compose.yml"
echo ""
echo "Update ERPNEXT_VERSION=${ERP_VERSION} on hyp1."
echo ""
+108
View File
@@ -0,0 +1,108 @@
name: erpnext-16
# --------------------------------------------------
# Custom ERPNext image
# --------------------------------------------------
x-erpnext-image: &erpnext-image
image: ${CUSTOM_IMAGE:?CUSTOM_IMAGE not set}:${CUSTOM_TAG:?CUSTOM_TAG not set}
pull_policy: always
services:
# ------------------------------------------------
# Configurator
# ------------------------------------------------
configurator:
<<: *erpnext-image
# ------------------------------------------------
# Backend
# ------------------------------------------------
backend:
<<: *erpnext-image
environment:
GUNICORN_THREADS: "${GUNICORN_THREADS:-4}"
GUNICORN_WORKERS: "${GUNICORN_WORKERS:-2}"
GUNICORN_TIMEOUT: "${GUNICORN_TIMEOUT:-120}"
# ------------------------------------------------
# Frontend / Nginx / Traefik
# ------------------------------------------------
frontend:
<<: *erpnext-image
environment:
NGINX_LISTEN_PORT: "${NGINX_LISTEN_PORT:-8080}"
FRAPPE_SITE_NAME_HEADER: ${FRAPPE_SITE_NAME_HEADER:-$$host}
UPSTREAM_REAL_IP_ADDRESS: ${UPSTREAM_REAL_IP_ADDRESS:-127.0.0.1}
UPSTREAM_REAL_IP_HEADER: ${UPSTREAM_REAL_IP_HEADER:-X-Forwarded-For}
UPSTREAM_REAL_IP_RECURSIVE: ${UPSTREAM_REAL_IP_RECURSIVE:-off}
PROXY_READ_TIMEOUT: "${PROXY_READ_TIMEOUT:-120}"
CLIENT_MAX_BODY_SIZE: ${CLIENT_MAX_BODY_SIZE:-50m}
networks:
- default
- proxy
labels:
traefik.enable: "true"
traefik.docker.network: proxy
# HTTPS
traefik.http.routers.erpnext-16-secure.entrypoints: websecure
traefik.http.routers.erpnext-16-secure.rule: ${SITES_RULE:?SITES_RULE not set}
traefik.http.routers.erpnext-16-secure.middlewares: default@file
traefik.http.routers.erpnext-16-secure.service: erpnext-16
traefik.http.routers.erpnext-16-secure.tls: "true"
traefik.http.routers.erpnext-16-secure.tls.certresolver: http_resolver
# HTTP
traefik.http.routers.erpnext-16.entrypoints: web
traefik.http.routers.erpnext-16.rule: ${SITES_RULE:?SITES_RULE not set}
traefik.http.routers.erpnext-16.service: erpnext-16
# Internal Nginx
traefik.http.services.erpnext-16.loadbalancer.server.port: "8080"
# ------------------------------------------------
# Websocket
# ------------------------------------------------
websocket:
<<: *erpnext-image
# ------------------------------------------------
# Background workers
# ------------------------------------------------
queue-short:
<<: *erpnext-image
queue-long:
<<: *erpnext-image
# ------------------------------------------------
# Scheduler
# ------------------------------------------------
scheduler:
<<: *erpnext-image
# ------------------------------------------------
# Dedicated MariaDB
# ------------------------------------------------
db:
environment:
MYSQL_ROOT_PASSWORD: ${DB_PASSWORD:?DB_PASSWORD not set}
# --------------------------------------------------
# External Traefik network
# --------------------------------------------------
networks:
proxy:
external: true
+236
View File
@@ -0,0 +1,236 @@
name: erpnext-16
services:
backend:
restart: unless-stopped
environment:
GUNICORN_THREADS: "4"
GUNICORN_TIMEOUT: "120"
GUNICORN_WORKERS: "2"
image: git.prothmann.com/christian/erpnexthp:16.53.0
networks:
default: null
platform: linux/amd64
pull_policy: always
volumes:
- type: volume
source: sites
target: /home/frappe/frappe-bench/sites
volume: {}
depends_on:
configurator:
condition: service_completed_successfully
required: true
configurator:
restart: on-failure
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; bench set-config -g chromium_path /usr/lib/chromium/chromium-headless-shell;
entrypoint:
- bash
- -c
environment:
DB_HOST: db
DB_PORT: "3306"
REDIS_CACHE: redis-cache:6379
REDIS_QUEUE: redis-queue:6379
SOCKETIO_PORT: "9000"
image: git.prothmann.com/christian/erpnexthp:16.53.0
networks:
default: null
platform: linux/amd64
pull_policy: always
volumes:
- type: volume
source: sites
target: /home/frappe/frappe-bench/sites
volume: {}
depends_on:
db:
condition: service_healthy
required: true
redis-cache:
condition: service_started
required: true
redis-queue:
condition: service_started
required: true
db:
restart: unless-stopped
command:
- --character-set-server=utf8mb4
- --collation-server=utf8mb4_unicode_ci
- --skip-character-set-client-handshake
environment:
MARIADB_AUTO_UPGRADE: "1"
MYSQL_ROOT_PASSWORD: TEMPLATE_ONLY
image: mariadb:11.8
networks:
default: null
volumes:
- type: volume
source: db-data
target: /var/lib/mysql
volume: {}
healthcheck:
test:
- CMD
- healthcheck.sh
- --connect
- --innodb_initialized
timeout: 5s
interval: 5s
retries: 5
start_period: 5s
frontend:
restart: unless-stopped
command:
- nginx-entrypoint.sh
environment:
BACKEND: backend:8000
CLIENT_MAX_BODY_SIZE: 50m
FRAPPE_SITE_NAME_HEADER: $$host
NGINX_LISTEN_PORT: "8080"
PROXY_READ_TIMEOUT: "120"
SOCKETIO: websocket:9000
UPSTREAM_REAL_IP_ADDRESS: 127.0.0.1
UPSTREAM_REAL_IP_HEADER: X-Forwarded-For
UPSTREAM_REAL_IP_RECURSIVE: 'off'
image: git.prothmann.com/christian/erpnexthp:16.53.0
networks:
default: null
platform: linux/amd64
pull_policy: always
volumes:
- type: volume
source: sites
target: /home/frappe/frappe-bench/sites
volume: {}
depends_on:
backend:
condition: service_started
required: true
websocket:
condition: service_started
required: true
queue-long:
restart: unless-stopped
command:
- bench
- worker
- --queue
- long,default,short
image: git.prothmann.com/christian/erpnexthp:16.53.0
networks:
default: null
platform: linux/amd64
pull_policy: always
volumes:
- type: volume
source: sites
target: /home/frappe/frappe-bench/sites
volume: {}
depends_on:
configurator:
condition: service_completed_successfully
required: true
queue-short:
restart: unless-stopped
command:
- bench
- worker
- --queue
- short,default
image: git.prothmann.com/christian/erpnexthp:16.53.0
networks:
default: null
platform: linux/amd64
pull_policy: always
volumes:
- type: volume
source: sites
target: /home/frappe/frappe-bench/sites
volume: {}
depends_on:
configurator:
condition: service_completed_successfully
required: true
redis-cache:
restart: unless-stopped
image: redis:8.6-alpine
networks:
default: null
redis-queue:
restart: unless-stopped
image: redis:8.6-alpine
networks:
default: null
volumes:
- type: volume
source: redis-queue-data
target: /data
volume: {}
scheduler:
restart: unless-stopped
command:
- bench
- schedule
image: git.prothmann.com/christian/erpnexthp:16.53.0
networks:
default: null
platform: linux/amd64
pull_policy: always
volumes:
- type: volume
source: sites
target: /home/frappe/frappe-bench/sites
volume: {}
depends_on:
configurator:
condition: service_completed_successfully
required: true
websocket:
restart: unless-stopped
command:
- node
- /home/frappe/frappe-bench/apps/frappe/socketio.js
image: git.prothmann.com/christian/erpnexthp:16.53.0
networks:
default: null
platform: linux/amd64
pull_policy: always
volumes:
- type: volume
source: sites
target: /home/frappe/frappe-bench/sites
volume: {}
depends_on:
configurator:
condition: service_completed_successfully
required: true
networks:
default:
name: erpnext-16_default
volumes:
db-data:
name: erpnext-16_db-data
redis-queue-data:
name: erpnext-16_redis-queue-data
sites:
name: erpnext-16_sites
x-backend-defaults:
depends_on:
configurator:
condition: service_completed_successfully
image: git.prothmann.com/christian/erpnexthp:16.53.0
pull_policy: always
restart: unless-stopped
volumes:
- sites:/home/frappe/frappe-bench/sites
x-customizable-image:
image: git.prothmann.com/christian/erpnexthp:16.53.0
pull_policy: always
restart: unless-stopped
x-depends-on-configurator:
depends_on:
configurator:
condition: service_completed_successfully
+58
View File
@@ -0,0 +1,58 @@
# --------------------------------------------
# Docker Compose
# --------------------------------------------
COMPOSE_PROJECT_NAME=erpnext-16
# --------------------------------------------
# ERPNext image
# --------------------------------------------
ERPNEXT_VERSION=16.53.0
CUSTOM_IMAGE=git.prothmann.com/christian/erpnexthp
CUSTOM_TAG=${ERPNEXT_VERSION}
PULL_POLICY=always
RESTART_POLICY=unless-stopped
# --------------------------------------------
# Dedicated MariaDB instance
# Generate with "openssl rand -hex 32"
# --------------------------------------------
DB_PASSWORD=REPLACE_WITH_SECURE_PASSWORD
# --------------------------------------------
# Gunicorn
# --------------------------------------------
GUNICORN_THREADS=4
GUNICORN_WORKERS=2
GUNICORN_TIMEOUT=120
# --------------------------------------------
# Frappe site
# --------------------------------------------
FRAPPE_SITE_NAME_HEADER=
# --------------------------------------------
# Nginx
# --------------------------------------------
NGINX_LISTEN_PORT=8080
UPSTREAM_REAL_IP_ADDRESS=
UPSTREAM_REAL_IP_HEADER=X-Forwarded-For
UPSTREAM_REAL_IP_RECURSIVE=off
PROXY_READ_TIMEOUT=120
CLIENT_MAX_BODY_SIZE=50m
# --------------------------------------------
# Traefik
# --------------------------------------------
SITES_RULE=Host(`erp16.prothmann.com`)