Added custom tags, auto install cups for network printing, added DOCKERFILE.cups

This commit is contained in:
Christian Anetzberger committed 2026-11-01 20:02:24 +01:00
1 parent b26b8f22a4
commit af045e325d
3 files changed
+142 -18

No files matched your search

+20
View File
@@ -0,0 +1,20 @@
# --------------------------------------------------
# Network printing support (CUPS / pycups)
# --------------------------------------------------
# Install native CUPS libraries and build dependencies
USER root
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
libcups2-dev \
build-essential \
pkg-config \
&& rm -rf /var/lib/apt/lists/*
# Install pycups in the Frappe virtual environment
USER frappe
RUN /home/frappe/frappe-bench/env/bin/python -m pip install --no-cache-dir pycups \
&& /home/frappe/frappe-bench/env/bin/python -c "import cups; print('pycups installed successfully')"
+120 -18
View File
@@ -13,11 +13,72 @@ FRAPPE_REPO="${FRAPPE_DOCKER_DIR:-${ROOT_DIR}/../frappe_docker}"
REGISTRY_IMAGE="git.prothmann.com/christian/erpnexthp"
BUILD_IMAGE="${REGISTRY_IMAGE}:build-local"
# --------------------------------------------------
# Optional command-line arguments
# --------------------------------------------------
REQUESTED_TAG=""
usage() {
echo "Usage: $0 [--tag TAG]"
echo ""
echo "Options:"
echo " --tag TAG Override the automatic ERPNext version tag"
echo " -h, --help Show this help message"
}
while [[ $# -gt 0 ]]; do
case "$1" in
--tag)
if [[ $# -lt 2 || -z "$2" ]]; then
echo "ERROR: --tag requires a value."
exit 1
fi
REQUESTED_TAG="$2"
shift 2
;;
--tag=*)
REQUESTED_TAG="${1#--tag=}"
shift
;;
-h|--help)
usage
exit 0
;;
*)
echo "ERROR: Unknown argument: $1"
usage
exit 1
;;
esac
done
# Validate custom Docker tag
if [[ -n "$REQUESTED_TAG" ]]; then
if [[ ! "$REQUESTED_TAG" =~ ^[a-zA-Z0-9_][a-zA-Z0-9_.-]{0,127}$ ]]; then
echo "ERROR: Invalid Docker image tag: $REQUESTED_TAG"
exit 1
fi
fi
# --------------------------------------------------
# Validate required files
# --------------------------------------------------
if [[ ! -f "${FRAPPE_REPO}/images/layered/Containerfile" ]]; then
echo "ERROR: frappe_docker repository not found."
exit 1
fi
if [[ ! -f "${ROOT_DIR}/Containerfile.cups" ]]; then
echo "ERROR: Missing Containerfile.cups"
exit 1
fi
if [[ ! -f "${ROOT_DIR}/docker-compose.override.yml" ]]; then
echo "ERROR: Missing docker-compose.override.yml"
exit 1
@@ -27,8 +88,9 @@ cd "$FRAPPE_REPO"
APPS_FILE="$(mktemp)"
COMPOSE_ENV_FILE="$(mktemp)"
BUILD_CONTAINERFILE="$(mktemp)"
trap 'rm -f "$APPS_FILE" "$COMPOSE_ENV_FILE"' EXIT
trap 'rm -f "$APPS_FILE" "$COMPOSE_ENV_FILE" "$BUILD_CONTAINERFILE"' EXIT
# --------------------------------------------------
# 1. Define applications
@@ -50,13 +112,28 @@ cat > "$APPS_FILE" <<'JSON'
},
{
"url": "https://git.prothmann.com/christian/manufacturing_utilities",
"branch": "test"
"branch": "version-16"
},
{
"url": "https://github.com/alyf-de/eu_einvoice.git",
"branch": "version-16"
}
]
JSON
# --------------------------------------------------
# 2. Build AMD64 production image
# 2. Prepare Containerfile with CUPS support
# --------------------------------------------------
echo "Preparing Frappe Docker image with CUPS support..."
cat \
"${FRAPPE_REPO}/images/layered/Containerfile" \
"${ROOT_DIR}/Containerfile.cups" \
> "$BUILD_CONTAINERFILE"
# --------------------------------------------------
# 3. Build AMD64 production image
# --------------------------------------------------
echo "Building ERPNext 16 for linux/amd64..."
@@ -70,11 +147,25 @@ docker buildx build \
--build-arg "CACHE_BUST=$(date -u +%s)" \
--secret "id=apps_json,src=${APPS_FILE}" \
--tag "${BUILD_IMAGE}" \
--file images/layered/Containerfile \
--file "$BUILD_CONTAINERFILE" \
.
# --------------------------------------------------
# 3. Detect actual ERPNext version
# 4. Verify CUPS support
# --------------------------------------------------
echo "Verifying pycups installation..."
docker run --rm \
--platform linux/amd64 \
--entrypoint /home/frappe/frappe-bench/env/bin/python \
"${BUILD_IMAGE}" \
-c "import cups; print('pycups is available')"
echo "CUPS support verified."
# --------------------------------------------------
# 5. Detect actual ERPNext version
# --------------------------------------------------
ERP_VERSION="$(
@@ -91,24 +182,32 @@ if [[ ! "$ERP_VERSION" =~ ^16\.[0-9]+\.[0-9]+$ ]]; then
exit 1
fi
FINAL_IMAGE="${REGISTRY_IMAGE}:${ERP_VERSION}"
echo "Detected ERPNext version: ${ERP_VERSION}"
# --------------------------------------------------
# 6. Determine final image tag
# --------------------------------------------------
if [[ -n "$REQUESTED_TAG" ]]; then
IMAGE_TAG="$REQUESTED_TAG"
echo "Using custom image tag: ${IMAGE_TAG}"
else
IMAGE_TAG="$ERP_VERSION"
echo "Using automatic image tag: ${IMAGE_TAG}"
fi
FINAL_IMAGE="${REGISTRY_IMAGE}:${IMAGE_TAG}"
docker tag "${BUILD_IMAGE}" "${FINAL_IMAGE}"
# --------------------------------------------------
# 4. Prepare temporary Compose environment
# 7. Prepare temporary Compose environment
# --------------------------------------------------
# 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"
printf 'CUSTOM_TAG=%s\n' "$IMAGE_TAG"
cat <<'ENV'
DB_PASSWORD=COMPOSE_TEMPLATE_ONLY
@@ -120,7 +219,7 @@ ENV
} > "$COMPOSE_ENV_FILE"
# --------------------------------------------------
# 5. Generate official production Compose
# 8. Generate official production Compose
# --------------------------------------------------
echo "Generating production Docker Compose..."
@@ -134,7 +233,7 @@ docker compose \
config > "${ROOT_DIR}/docker-compose.yml"
# --------------------------------------------------
# 6. Validate final configuration
# 9. Validate final configuration
# --------------------------------------------------
echo "Validating Docker Compose..."
@@ -149,7 +248,7 @@ docker compose \
echo "Docker Compose validation successful."
# --------------------------------------------------
# 7. Push image to Gitea
# 10. Push image to Gitea
# --------------------------------------------------
echo "Publishing ${FINAL_IMAGE}..."
@@ -157,7 +256,7 @@ echo "Publishing ${FINAL_IMAGE}..."
docker push "${FINAL_IMAGE}"
# --------------------------------------------------
# 8. Summary
# 11. Summary
# --------------------------------------------------
echo ""
@@ -166,8 +265,11 @@ echo " ERPNext production build completed"
echo "============================================"
echo ""
echo "ERPNext version: ${ERP_VERSION}"
echo "Image tag: ${IMAGE_TAG}"
echo "Docker image: ${FINAL_IMAGE}"
echo "CUPS support: Installed and verified"
echo "Compose file: ${ROOT_DIR}/docker-compose.yml"
echo ""
echo "Update ERPNEXT_VERSION=${ERP_VERSION} on hyp1."
echo "To deploy on hyp1, set:"
echo "CUSTOM_TAG=${IMAGE_TAG}"
echo ""
+2
View File
@@ -12,6 +12,8 @@ COMPOSE_PROJECT_NAME=erpnext-16
ERPNEXT_VERSION=16.53.0
CUSTOM_IMAGE=git.prothmann.com/christian/erpnexthp
# Default: CUSTOM_TAG=${ERPNEXT_VERSION}
# Custom: CUSTOM_TAG=16.53.0-cups-test
CUSTOM_TAG=${ERPNEXT_VERSION}
PULL_POLICY=always