Merge pull request #9256 from dokku/9217-source-installs-fail-on-arm64-because-the-makefile-defaults-to-amd64
fix: default source installs to the host architecture
This commit is contained in:
4
Makefile
4
Makefile
@@ -1,6 +1,6 @@
|
||||
DOKKU_VERSION ?= master
|
||||
|
||||
TARGETARCH ?= amd64
|
||||
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)
|
||||
@@ -31,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
|
||||
|
||||
2
Vagrantfile
vendored
2
Vagrantfile
vendored
@@ -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
|
||||
|
||||
@@ -5,7 +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)
|
||||
GOARCH ?= amd64
|
||||
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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
2
deb.mk
2
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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
GOARCH ?= amd64
|
||||
TRIGGERS = triggers/report
|
||||
BUILD = report-subcommand triggers
|
||||
PLUGIN_NAME = builder-dockerfile
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
GOARCH ?= amd64
|
||||
TRIGGERS = triggers/report
|
||||
BUILD = report-subcommand triggers
|
||||
PLUGIN_NAME = builder-herokuish
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
GOARCH ?= amd64
|
||||
TRIGGERS = triggers/report
|
||||
BUILD = report-subcommand triggers
|
||||
PLUGIN_NAME = builder-lambda
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
GOARCH ?= amd64
|
||||
TRIGGERS = triggers/report
|
||||
BUILD = report-subcommand triggers
|
||||
PLUGIN_NAME = builder-nixpacks
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
GOARCH ?= amd64
|
||||
TRIGGERS = triggers/report
|
||||
BUILD = report-subcommand triggers
|
||||
PLUGIN_NAME = builder-pack
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
GOARCH ?= amd64
|
||||
TRIGGERS = triggers/report
|
||||
BUILD = report-subcommand triggers
|
||||
PLUGIN_NAME = builder-railpack
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
GOARCH ?= amd64
|
||||
TRIGGERS = triggers/report
|
||||
BUILD = report-subcommand triggers
|
||||
PLUGIN_NAME = caddy-vhosts
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
GOARCH ?= amd64
|
||||
TRIGGERS = triggers/report
|
||||
BUILD = report-subcommand triggers
|
||||
PLUGIN_NAME = certs
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
GOARCH ?= amd64
|
||||
TRIGGERS = triggers/report
|
||||
BUILD = report-subcommand triggers
|
||||
PLUGIN_NAME = checks
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
GOARCH ?= amd64
|
||||
TRIGGERS = triggers/report
|
||||
BUILD = report-subcommand triggers
|
||||
PLUGIN_NAME = domains
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
GOARCH ?= amd64
|
||||
TRIGGERS = triggers/report
|
||||
BUILD = report-subcommand triggers
|
||||
PLUGIN_NAME = git
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
GOARCH ?= amd64
|
||||
TRIGGERS = triggers/report
|
||||
BUILD = report-subcommand triggers
|
||||
PLUGIN_NAME = haproxy-vhosts
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
GOARCH ?= amd64
|
||||
TRIGGERS = triggers/report
|
||||
BUILD = pagesize nginx-property report-subcommand triggers
|
||||
PLUGIN_NAME = nginx-vhosts
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
GOARCH ?= amd64
|
||||
TRIGGERS = triggers/report
|
||||
BUILD = report-subcommand triggers
|
||||
PLUGIN_NAME = openresty-vhosts
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
GOARCH ?= amd64
|
||||
BUILD = plugin-list
|
||||
PLUGIN_NAME = plugin
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
GOARCH ?= amd64
|
||||
TRIGGERS = triggers/report
|
||||
BUILD = report-subcommand triggers
|
||||
PLUGIN_NAME = traefik-vhosts
|
||||
|
||||
67
tests/unit/makefile-arch.bats
Normal file
67
tests/unit/makefile-arch.bats
Normal file
@@ -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"
|
||||
}
|
||||
Reference in New Issue
Block a user