From 825fa8968cf5733d53939345d3bc1f6035f52dee Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Fri, 6 Nov 2026 17:11:28 -0500 Subject: [PATCH 1/2] fix: default source installs to the host architecture Installing from source on an arm64 host downloaded amd64 dependencies and built amd64 plugins, failing once `plugin:install` ran the first binary. The `TARGETARCH` and `GOARCH` make variables now default to the host architecture and remain overridable, and debian packages are labelled with the architecture they were built for. Closes #9217. --- Makefile | 3 +- Vagrantfile | 2 +- common.mk | 3 +- contrib/build-dokku.Dockerfile | 4 +- deb.mk | 2 +- docs/getting-started/advanced-installation.md | 6 ++ plugins/builder-dockerfile/Makefile | 1 - plugins/builder-herokuish/Makefile | 1 - plugins/builder-lambda/Makefile | 1 - plugins/builder-nixpacks/Makefile | 1 - plugins/builder-pack/Makefile | 1 - plugins/builder-railpack/Makefile | 1 - plugins/caddy-vhosts/Makefile | 1 - plugins/certs/Makefile | 1 - plugins/checks/Makefile | 1 - plugins/common/Makefile | 1 - plugins/config/Makefile | 1 - plugins/domains/Makefile | 1 - plugins/git/Makefile | 1 - plugins/haproxy-vhosts/Makefile | 1 - plugins/nginx-vhosts/Makefile | 1 - plugins/openresty-vhosts/Makefile | 1 - plugins/plugin/Makefile | 1 - plugins/storage/Makefile | 1 - plugins/traefik-vhosts/Makefile | 1 - tests/unit/makefile-arch.bats | 67 +++++++++++++++++++ 26 files changed, 81 insertions(+), 25 deletions(-) create mode 100644 tests/unit/makefile-arch.bats diff --git a/Makefile b/Makefile index 955912058..1901fe7a2 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ DOKKU_VERSION ?= master -TARGETARCH ?= amd64 +TARGETARCH ?= $(HOST_ARCH) +GOARCH ?= $(TARGETARCH) DOCKER_IMAGE_LABELER_URL ?= $(shell jq -r --arg name docker-image-labeler --arg arch $(TARGETARCH) '.dependencies[] | select(.name == $$name) | .urls[$$arch]' contrib/dependencies.json) DOCKER_CONTAINER_HEALTHCHECKER_URL ?= $(shell jq -r --arg name docker-container-healthchecker --arg arch $(TARGETARCH) '.dependencies[] | select(.name == $$name) | .urls[$$arch]' contrib/dependencies.json) diff --git a/Vagrantfile b/Vagrantfile index 1c4552eaa..543a094be 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -9,7 +9,7 @@ DOKKU_IP = ENV["DOKKU_IP"] || "10.0.0.2" PREBUILT_STACK_URL = File.exist?("#{File.dirname(__FILE__)}/stack.tgz") ? 'file:///root/dokku/stack.tgz' : nil PUBLIC_KEY_PATH = "#{Dir.home}/.ssh/id_rsa.pub" -make_cmd = "TARGETARCH=$(dpkg --print-architecture) DEBIAN_FRONTEND=noninteractive make -e install" +make_cmd = "DEBIAN_FRONTEND=noninteractive make -e install" if PREBUILT_STACK_URL make_cmd = "PREBUILT_STACK_URL='#{PREBUILT_STACK_URL}' #{make_cmd}" end diff --git a/common.mk b/common.mk index 2df96b56a..e68196cb2 100644 --- a/common.mk +++ b/common.mk @@ -5,7 +5,8 @@ BUILD_IMAGE := golang:1.27.1 GO_BUILD_CACHE ?= /tmp/dokku-go-build-cache GO_MOD_CACHE ?= /tmp/dokku-go-mod-mod GO_ROOT_MOUNT ?= $$PWD/../..:$(GO_REPO_ROOT) -GOARCH ?= amd64 +HOST_ARCH := $(shell dpkg --print-architecture 2>/dev/null || uname -m | sed -e 's/x86_64/amd64/' -e 's/aarch64/arm64/') +GOARCH ?= $(HOST_ARCH) .PHONY: build-in-docker build clean src-clean diff --git a/contrib/build-dokku.Dockerfile b/contrib/build-dokku.Dockerfile index 7f08388fa..4a4a80dc8 100644 --- a/contrib/build-dokku.Dockerfile +++ b/contrib/build-dokku.Dockerfile @@ -35,8 +35,8 @@ RUN PLUGIN_MAKE_TARGET=${PLUGIN_MAKE_TARGET} \ DOKKU_GIT_REV=${DOKKU_GIT_REV} \ IS_RELEASE=${IS_RELEASE} \ SKIP_GO_CLEAN=true \ - make version copyfiles \ - && make deb-dokku + GOARCH=amd64 make version copyfiles \ + && DOKKU_ARCHITECTURE=amd64 GOARCH=amd64 make deb-dokku FROM builder AS arm64 diff --git a/deb.mk b/deb.mk index 528c0177e..d9a32909b 100644 --- a/deb.mk +++ b/deb.mk @@ -1,7 +1,7 @@ BUILD_DIRECTORY ?= /tmp DOKKU_DESCRIPTION = 'Docker powered PaaS that helps you build and manage the lifecycle of applications' DOKKU_REPO_NAME ?= dokku/dokku -DOKKU_ARCHITECTURE ?= amd64 +DOKKU_ARCHITECTURE ?= $(GOARCH) ifndef IS_RELEASE IS_RELEASE = true diff --git a/docs/getting-started/advanced-installation.md b/docs/getting-started/advanced-installation.md index 4a1a1564c..34ebcf986 100644 --- a/docs/getting-started/advanced-installation.md +++ b/docs/getting-started/advanced-installation.md @@ -36,6 +36,12 @@ cd dokku sudo make install ``` +The `Makefile` installs dependencies and builds plugins for the architecture of the host it runs on. The `TARGETARCH` environment variable overrides the architecture used for both the downloaded dependencies and the plugin builds, while the `GOARCH` environment variable overrides the architecture used for the plugin builds only. Example: + +```shell +sudo TARGETARCH=arm64 make install +``` + The `Makefile` allows source URLs to be overridden to include customizations from your own repositories. The `DOCKER_URL`, `PLUGN_URL`, `SSHCOMMAND_URL` and `STACK_URL` environment variables may be set to override the defaults (see the `Makefile` for how these apply). Example: ```shell diff --git a/plugins/builder-dockerfile/Makefile b/plugins/builder-dockerfile/Makefile index be9dbcce5..753d42334 100644 --- a/plugins/builder-dockerfile/Makefile +++ b/plugins/builder-dockerfile/Makefile @@ -1,4 +1,3 @@ -GOARCH ?= amd64 TRIGGERS = triggers/report BUILD = report-subcommand triggers PLUGIN_NAME = builder-dockerfile diff --git a/plugins/builder-herokuish/Makefile b/plugins/builder-herokuish/Makefile index 716f94f54..4a9688fd8 100644 --- a/plugins/builder-herokuish/Makefile +++ b/plugins/builder-herokuish/Makefile @@ -1,4 +1,3 @@ -GOARCH ?= amd64 TRIGGERS = triggers/report BUILD = report-subcommand triggers PLUGIN_NAME = builder-herokuish diff --git a/plugins/builder-lambda/Makefile b/plugins/builder-lambda/Makefile index 7c29679a8..03457bab8 100644 --- a/plugins/builder-lambda/Makefile +++ b/plugins/builder-lambda/Makefile @@ -1,4 +1,3 @@ -GOARCH ?= amd64 TRIGGERS = triggers/report BUILD = report-subcommand triggers PLUGIN_NAME = builder-lambda diff --git a/plugins/builder-nixpacks/Makefile b/plugins/builder-nixpacks/Makefile index 79979a35e..0d7811801 100644 --- a/plugins/builder-nixpacks/Makefile +++ b/plugins/builder-nixpacks/Makefile @@ -1,4 +1,3 @@ -GOARCH ?= amd64 TRIGGERS = triggers/report BUILD = report-subcommand triggers PLUGIN_NAME = builder-nixpacks diff --git a/plugins/builder-pack/Makefile b/plugins/builder-pack/Makefile index ab09df0e2..c287d59ec 100644 --- a/plugins/builder-pack/Makefile +++ b/plugins/builder-pack/Makefile @@ -1,4 +1,3 @@ -GOARCH ?= amd64 TRIGGERS = triggers/report BUILD = report-subcommand triggers PLUGIN_NAME = builder-pack diff --git a/plugins/builder-railpack/Makefile b/plugins/builder-railpack/Makefile index 73f557fa4..4a82e7a28 100644 --- a/plugins/builder-railpack/Makefile +++ b/plugins/builder-railpack/Makefile @@ -1,4 +1,3 @@ -GOARCH ?= amd64 TRIGGERS = triggers/report BUILD = report-subcommand triggers PLUGIN_NAME = builder-railpack diff --git a/plugins/caddy-vhosts/Makefile b/plugins/caddy-vhosts/Makefile index f0ee8b444..596187a1a 100644 --- a/plugins/caddy-vhosts/Makefile +++ b/plugins/caddy-vhosts/Makefile @@ -1,4 +1,3 @@ -GOARCH ?= amd64 TRIGGERS = triggers/report BUILD = report-subcommand triggers PLUGIN_NAME = caddy-vhosts diff --git a/plugins/certs/Makefile b/plugins/certs/Makefile index 92ef9be66..275146a7a 100644 --- a/plugins/certs/Makefile +++ b/plugins/certs/Makefile @@ -1,4 +1,3 @@ -GOARCH ?= amd64 TRIGGERS = triggers/report BUILD = report-subcommand triggers PLUGIN_NAME = certs diff --git a/plugins/checks/Makefile b/plugins/checks/Makefile index 0cfaa38e7..ba54cfa35 100644 --- a/plugins/checks/Makefile +++ b/plugins/checks/Makefile @@ -1,4 +1,3 @@ -GOARCH ?= amd64 TRIGGERS = triggers/report BUILD = report-subcommand triggers PLUGIN_NAME = checks diff --git a/plugins/common/Makefile b/plugins/common/Makefile index 7fa54b840..f2c4686ce 100644 --- a/plugins/common/Makefile +++ b/plugins/common/Makefile @@ -1,4 +1,3 @@ -GOARCH ?= amd64 TRIGGERS = triggers/app-list triggers/core-post-deploy triggers/install triggers/post-delete BUILD = prop common triggers PLUGIN_NAME = common diff --git a/plugins/config/Makefile b/plugins/config/Makefile index a27152cf4..70a3d3cfd 100644 --- a/plugins/config/Makefile +++ b/plugins/config/Makefile @@ -1,4 +1,3 @@ -GOARCH ?= amd64 SUBCOMMANDS = subcommands/bundle subcommands/clear subcommands/export subcommands/get subcommands/import subcommands/keys subcommands/show subcommands/set subcommands/unset TRIGGERS = triggers/config-export triggers/config-get triggers/config-get-global triggers/config-migrate-env triggers/install triggers/config-set triggers/config-unset triggers/post-app-clone-setup triggers/post-app-rename-setup triggers/post-create triggers/post-delete BUILD = commands config_sub subcommands triggers diff --git a/plugins/domains/Makefile b/plugins/domains/Makefile index c4698f30c..9612a5c2c 100644 --- a/plugins/domains/Makefile +++ b/plugins/domains/Makefile @@ -1,4 +1,3 @@ -GOARCH ?= amd64 TRIGGERS = triggers/report BUILD = report-subcommand triggers PLUGIN_NAME = domains diff --git a/plugins/git/Makefile b/plugins/git/Makefile index 4a17c4b2a..1888e3dd8 100644 --- a/plugins/git/Makefile +++ b/plugins/git/Makefile @@ -1,4 +1,3 @@ -GOARCH ?= amd64 TRIGGERS = triggers/report BUILD = report-subcommand triggers PLUGIN_NAME = git diff --git a/plugins/haproxy-vhosts/Makefile b/plugins/haproxy-vhosts/Makefile index b727ed3b4..e402aded8 100644 --- a/plugins/haproxy-vhosts/Makefile +++ b/plugins/haproxy-vhosts/Makefile @@ -1,4 +1,3 @@ -GOARCH ?= amd64 TRIGGERS = triggers/report BUILD = report-subcommand triggers PLUGIN_NAME = haproxy-vhosts diff --git a/plugins/nginx-vhosts/Makefile b/plugins/nginx-vhosts/Makefile index 8c14028f8..31da02481 100644 --- a/plugins/nginx-vhosts/Makefile +++ b/plugins/nginx-vhosts/Makefile @@ -1,4 +1,3 @@ -GOARCH ?= amd64 TRIGGERS = triggers/report BUILD = pagesize nginx-property report-subcommand triggers PLUGIN_NAME = nginx-vhosts diff --git a/plugins/openresty-vhosts/Makefile b/plugins/openresty-vhosts/Makefile index b300b082d..aec3151a8 100644 --- a/plugins/openresty-vhosts/Makefile +++ b/plugins/openresty-vhosts/Makefile @@ -1,4 +1,3 @@ -GOARCH ?= amd64 TRIGGERS = triggers/report BUILD = report-subcommand triggers PLUGIN_NAME = openresty-vhosts diff --git a/plugins/plugin/Makefile b/plugins/plugin/Makefile index d3455e6be..35dcf9889 100644 --- a/plugins/plugin/Makefile +++ b/plugins/plugin/Makefile @@ -1,4 +1,3 @@ -GOARCH ?= amd64 BUILD = plugin-list PLUGIN_NAME = plugin diff --git a/plugins/storage/Makefile b/plugins/storage/Makefile index 1b2e6b558..e08a7683e 100644 --- a/plugins/storage/Makefile +++ b/plugins/storage/Makefile @@ -1,4 +1,3 @@ -GOARCH ?= amd64 SUBCOMMANDS = subcommands/default subcommands/annotations:set subcommands/annotations:report subcommands/create subcommands/destroy subcommands/ensure-directory subcommands/exec subcommands/info subcommands/labels:set subcommands/labels:report subcommands/list subcommands/list-entries subcommands/migrate subcommands/mount subcommands/report subcommands/set subcommands/unmount subcommands/wait TRIGGERS = triggers/install triggers/storage-list triggers/storage-app-mounts triggers/docker-args-process-deploy triggers/docker-args-run triggers/post-delete triggers/post-app-clone-setup triggers/post-app-rename-setup BUILD = commands subcommands triggers diff --git a/plugins/traefik-vhosts/Makefile b/plugins/traefik-vhosts/Makefile index e868730fe..54912710d 100644 --- a/plugins/traefik-vhosts/Makefile +++ b/plugins/traefik-vhosts/Makefile @@ -1,4 +1,3 @@ -GOARCH ?= amd64 TRIGGERS = triggers/report BUILD = report-subcommand triggers PLUGIN_NAME = traefik-vhosts diff --git a/tests/unit/makefile-arch.bats b/tests/unit/makefile-arch.bats new file mode 100644 index 000000000..4e26fbf80 --- /dev/null +++ b/tests/unit/makefile-arch.bats @@ -0,0 +1,67 @@ +#!/usr/bin/env bats + +load test_helper + +setup() { + REPO_ROOT="$(cd "$BATS_TEST_DIRNAME/../.." && pwd)" + HOST_ARCH="$(dpkg --print-architecture)" + OTHER_ARCH="amd64" + if [[ "$HOST_ARCH" == "amd64" ]]; then + OTHER_ARCH="arm64" + fi +} + +@test "(makefile) [arch] dependency urls default to the host architecture" { + run make -n -C "$REPO_ROOT" docker-image-labeler + echo "output: $output" + echo "status: $status" + assert_success + assert_output_contains "$(dependency_url docker-image-labeler "$HOST_ARCH")" -1 +} + +@test "(makefile) [arch] TARGETARCH overrides the dependency architecture" { + run env TARGETARCH="$OTHER_ARCH" make -n -C "$REPO_ROOT" docker-image-labeler + echo "output: $output" + echo "status: $status" + assert_success + assert_output_contains "$(dependency_url docker-image-labeler "$OTHER_ARCH")" -1 +} + +@test "(makefile) [arch] plugin builds default to the host architecture" { + run make -B -n -C "$REPO_ROOT" go-build-plugin PLUGIN_NAME=common PLUGIN_MAKE_TARGET=build + echo "output: $output" + echo "status: $status" + assert_success + assert_output_contains "GOARCH=$HOST_ARCH go build" -1 + assert_output_contains "GOARCH=$OTHER_ARCH" 0 +} + +@test "(makefile) [arch] TARGETARCH sets the plugin build architecture" { + run env TARGETARCH="$OTHER_ARCH" make -B -n -C "$REPO_ROOT" go-build-plugin PLUGIN_NAME=common PLUGIN_MAKE_TARGET=build + echo "output: $output" + echo "status: $status" + assert_success + assert_output_contains "GOARCH=$OTHER_ARCH go build" -1 + assert_output_contains "GOARCH=$HOST_ARCH" 0 +} + +@test "(makefile) [arch] GOARCH overrides the plugin build architecture" { + run env GOARCH="$OTHER_ARCH" make -B -n -C "$REPO_ROOT" go-build-plugin PLUGIN_NAME=common PLUGIN_MAKE_TARGET=build + echo "output: $output" + echo "status: $status" + assert_success + assert_output_contains "GOARCH=$OTHER_ARCH go build" -1 + assert_output_contains "GOARCH=$HOST_ARCH" 0 + + run env GOARCH="$OTHER_ARCH" make -n -C "$REPO_ROOT" docker-image-labeler + echo "output: $output" + echo "status: $status" + assert_success + assert_output_contains "$(dependency_url docker-image-labeler "$HOST_ARCH")" -1 +} + +dependency_url() { + declare desc="print the url for a dependency in contrib/dependencies.json" + declare NAME="$1" ARCH="$2" + jq -r --arg name "$NAME" --arg arch "$ARCH" '.dependencies[] | select(.name == $name) | .urls[$arch]' "$REPO_ROOT/contrib/dependencies.json" +} From 3d4a6b5981eafec631c40d8608e4f4ab34c8d671 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Fri, 6 Nov 2026 19:55:44 -0500 Subject: [PATCH 2/2] refactor: define TARGETARCH once in common.mk --- Makefile | 5 +---- common.mk | 6 ++++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 1901fe7a2..8ae4edf8b 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,6 @@ DOKKU_VERSION ?= master -TARGETARCH ?= $(HOST_ARCH) -GOARCH ?= $(TARGETARCH) +include common.mk DOCKER_IMAGE_LABELER_URL ?= $(shell jq -r --arg name docker-image-labeler --arg arch $(TARGETARCH) '.dependencies[] | select(.name == $$name) | .urls[$$arch]' contrib/dependencies.json) DOCKER_CONTAINER_HEALTHCHECKER_URL ?= $(shell jq -r --arg name docker-container-healthchecker --arg arch $(TARGETARCH) '.dependencies[] | select(.name == $$name) | .urls[$$arch]' contrib/dependencies.json) @@ -32,8 +31,6 @@ else BUILD_STACK_TARGETS = build-in-docker endif -include common.mk - .PHONY: all apt-update install version copyfiles copyplugin man-db plugins dependencies docker-image-labeler lambda-builder netrc sshcommand procfile-util plugn docker aufs stack count vagrant-acl-add vagrant-dokku go-build wget include docs.mk diff --git a/common.mk b/common.mk index e68196cb2..d93a042c3 100644 --- a/common.mk +++ b/common.mk @@ -5,8 +5,10 @@ BUILD_IMAGE := golang:1.27.1 GO_BUILD_CACHE ?= /tmp/dokku-go-build-cache GO_MOD_CACHE ?= /tmp/dokku-go-mod-mod GO_ROOT_MOUNT ?= $$PWD/../..:$(GO_REPO_ROOT) -HOST_ARCH := $(shell dpkg --print-architecture 2>/dev/null || uname -m | sed -e 's/x86_64/amd64/' -e 's/aarch64/arm64/') -GOARCH ?= $(HOST_ARCH) +ifndef TARGETARCH +TARGETARCH := $(shell dpkg --print-architecture 2>/dev/null || uname -m | sed -e 's/x86_64/amd64/' -e 's/aarch64/arm64/') +endif +GOARCH ?= $(TARGETARCH) .PHONY: build-in-docker build clean src-clean