From b0805a043436038fc1b82fbe33d176029f56c606 Mon Sep 17 00:00:00 2001 From: JasonFraser Date: Fri, 2 Oct 2026 07:20:35 -0400 Subject: [PATCH] Fix cross-platform build: push linux/amd64, keep local builds on host arch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Confirmed the hard way on a real Dokploy deploy: a plain `docker build` on this Apple Silicon Mac produces an arm64-only image, so the amd64 Dokploy VPS failed to pull either custom image ("no matching manifest for linux/amd64") for configurator/backend/frontend (erpnext-image) and backend-billing alike. Both build.sh scripts now branch on whether BACKEND_BILLING_IMAGE/ CUSTOM_IMAGE is a registry path: a bare local tag still builds for this machine's own architecture (so it runs immediately for local dev), while a registry path builds specifically for linux/amd64 via buildx (with --push, since a cross-platform result can't be loaded into the local image store) — matching the actual Dokploy VPS target regardless of what architecture the build machine is. erpnext-image/build.sh previously had no push step at all; added one following the same pattern. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_012pc2x7vyuUofdT3kLuqF3Y --- backend/build.sh | 29 ++++++++++++++++++---------- erpnext-image/build.sh | 43 ++++++++++++++++++++++++++++++++++-------- 2 files changed, 54 insertions(+), 18 deletions(-) diff --git a/backend/build.sh b/backend/build.sh index d4d1357..5cff499 100755 --- a/backend/build.sh +++ b/backend/build.sh @@ -46,15 +46,15 @@ BACKEND_BILLING_IMAGE="${BACKEND_BILLING_IMAGE:-sightbox-backend-billing}" BACKEND_BILLING_TAG="${BACKEND_BILLING_TAG:-latest}" FULL_TAG="${BACKEND_BILLING_IMAGE}:${BACKEND_BILLING_TAG}" -echo "Building ${FULL_TAG} from ${SCRIPT_DIR}/Dockerfile" -docker build -t "${FULL_TAG}" "${SCRIPT_DIR}" -echo -echo "Built ${FULL_TAG}." - # A bare local tag (no "/" at all, e.g. "sightbox-backend-billing") means -# "local dev only" — nothing to push, nothing to redeploy. A registry path -# always has at least one "/" (host/owner/name or owner/name). +# "local dev only" — build for this machine's own architecture so it runs +# immediately, nothing to push, nothing to redeploy. A registry path always +# has at least one "/" (host/owner/name or owner/name). if [[ "${BACKEND_BILLING_IMAGE}" != */* ]]; then + echo "Building ${FULL_TAG} (local dev, host architecture) from ${SCRIPT_DIR}/Dockerfile" + docker build -t "${FULL_TAG}" "${SCRIPT_DIR}" + echo + echo "Built ${FULL_TAG}." echo "BACKEND_BILLING_IMAGE has no registry path (just \"${BACKEND_BILLING_IMAGE}\") — local build only." echo "Set in .env (see .env.example):" echo " BACKEND_BILLING_IMAGE=${BACKEND_BILLING_IMAGE}" @@ -63,9 +63,18 @@ if [[ "${BACKEND_BILLING_IMAGE}" != */* ]]; then exit 0 fi -echo "Pushing ${FULL_TAG}..." -docker push "${FULL_TAG}" -echo "Pushed." +# A registry path: build specifically for linux/amd64, the real Dokploy VPS +# target — confirmed the hard way: a plain `docker build` on an Apple +# Silicon Mac produces an arm64-only image with no amd64 manifest entry, so +# the (amd64) VPS fails to pull it ("no matching manifest for linux/amd64"). +# buildx --platform forces the amd64 target regardless of this machine's +# own architecture (via QEMU emulation if needed); --push uploads the +# result directly, since a cross-platform buildx result can't be loaded +# into the local `docker images` store the way a same-arch build can. +echo "Building ${FULL_TAG} for linux/amd64 (Dokploy VPS target) from ${SCRIPT_DIR}/Dockerfile" +docker buildx build --platform linux/amd64 -t "${FULL_TAG}" --push "${SCRIPT_DIR}" +echo +echo "Built and pushed ${FULL_TAG}." if [[ -z "${DOKPLOY_URL:-}" || -z "${DOKPLOY_API_TOKEN:-}" || -z "${DOKPLOY_COMPOSE_ID:-}" ]]; then echo diff --git a/erpnext-image/build.sh b/erpnext-image/build.sh index 4ca3be9..6326150 100755 --- a/erpnext-image/build.sh +++ b/erpnext-image/build.sh @@ -25,16 +25,43 @@ fi ERPNEXT_VERSION="${ERPNEXT_VERSION:?Set ERPNEXT_VERSION in .env first (see .env.example)}" CUSTOM_IMAGE="${CUSTOM_IMAGE:-sightbox-erpnext}" CUSTOM_TAG="${CUSTOM_TAG:-${ERPNEXT_VERSION}-branded}" +FULL_TAG="${CUSTOM_IMAGE}:${CUSTOM_TAG}" -echo "Building ${CUSTOM_IMAGE}:${CUSTOM_TAG} from frappe/erpnext:${ERPNEXT_VERSION}" -docker build \ +# A bare local tag (no "/" at all, e.g. "sightbox-erpnext") means "local dev +# only" — build for this machine's own architecture so it runs immediately, +# nothing to push. A registry path always has at least one "/" +# (host/owner/name or owner/name). +if [[ "${CUSTOM_IMAGE}" != */* ]]; then + echo "Building ${FULL_TAG} (local dev, host architecture) from frappe/erpnext:${ERPNEXT_VERSION}" + docker build \ + --build-arg "ERPNEXT_VERSION=${ERPNEXT_VERSION}" \ + -t "${FULL_TAG}" \ + "${SCRIPT_DIR}" + echo + echo "Built ${FULL_TAG}." + echo "Set in .env (see .env.example):" + echo " CUSTOM_IMAGE=${CUSTOM_IMAGE}" + echo " CUSTOM_TAG=${CUSTOM_TAG}" + echo "Then: docker compose up -d --force-recreate configurator backend frontend websocket queue-short queue-long scheduler" + exit 0 +fi + +# A registry path: build specifically for linux/amd64, the real Dokploy VPS +# target — confirmed the hard way: a plain `docker build` on an Apple +# Silicon Mac produces an arm64-only image with no amd64 manifest entry, so +# the (amd64) VPS fails to pull it ("no matching manifest for linux/amd64"). +# buildx --platform forces the amd64 target regardless of this machine's +# own architecture (via QEMU emulation if needed); --push uploads the +# result directly, since a cross-platform buildx result can't be loaded +# into the local `docker images` store the way a same-arch build can. +echo "Building ${FULL_TAG} for linux/amd64 (Dokploy VPS target) from frappe/erpnext:${ERPNEXT_VERSION}" +docker buildx build \ + --platform linux/amd64 \ --build-arg "ERPNEXT_VERSION=${ERPNEXT_VERSION}" \ - -t "${CUSTOM_IMAGE}:${CUSTOM_TAG}" \ + -t "${FULL_TAG}" \ + --push \ "${SCRIPT_DIR}" echo -echo "Built ${CUSTOM_IMAGE}:${CUSTOM_TAG}." -echo "Set in .env (see .env.example):" -echo " CUSTOM_IMAGE=${CUSTOM_IMAGE}" -echo " CUSTOM_TAG=${CUSTOM_TAG}" -echo "Then: docker compose up -d --force-recreate configurator backend frontend websocket queue-short queue-long scheduler" +echo "Built and pushed ${FULL_TAG}." +echo "Then: redeploy in Dokploy, or docker compose up -d --force-recreate configurator backend frontend websocket queue-short queue-long scheduler"