feat: set the platform flag in order to run amd64 images on arm64 deploy targets

This allows folks to use herokuish, pack, and lambda built-images on arm64 servers.

Closes #6312
This commit is contained in:
Jose Diaz-Gonzalez
2023-10-27 23:02:08 -04:00
parent ea28367689
commit 874f2dfaf4
3 changed files with 18 additions and 0 deletions

View File

@@ -25,6 +25,12 @@ dokku scheduler:set node-js-app selected
## Usage
### Deploying amd64 images on arm64
> New as of 0.33.0
Many builders only produce amd64-compatible images. The docker-local scheduler will automatically detect these and run them via the `--platform=linux/amd64` on arm64 deploy targets.
### Disabling chown of persistent storage
The `scheduler-docker-local` plugin will ensure your storage mounts are owned by either `herokuishuser` or the overridden value you have set in `DOKKU_APP_USER`. You may disable this by running the following `scheduler-docker-local:set` command for your application:

View File

@@ -49,6 +49,12 @@ main() {
DOCKER_ARGS+=" --env=PORT=$DOKKU_PORT"
local DOKKU_IMAGE_ARCHITECTURE="$("$DOCKER_BIN" image inspect --format '{{.Architecture}}' "$IMAGE")"
if [[ "$DOKKU_IMAGE_ARCHITECTURE" == "amd64" ]] && [[ "$(dpkg --print-architecture 2>/dev/null || true)" != "amd64" ]]; then
dokku_log_warn "Detected linux/amd64 image, forcing --platform=linux/amd64"
DOCKER_ARGS+=" --platform=linux/amd64"
fi
START_CMD=$(fn-scheduler-docker-local-extract-start-cmd "$APP" "$PROC_TYPE" "$START_CMD" "$DOKKU_HEROKUISH" "$DOKKU_PORT")
DOCKER_ARGS+=" $IMAGE"
DOCKER_ARGS+=" $START_CMD"

View File

@@ -87,6 +87,12 @@ trigger-scheduler-docker-local-scheduler-run() {
fi
fi
local DOKKU_IMAGE_ARCHITECTURE="$("$DOCKER_BIN" image inspect --format '{{.Architecture}}' "$IMAGE")"
if [[ "$DOKKU_IMAGE_ARCHITECTURE" == "amd64" ]] && [[ "$(dpkg --print-architecture 2>/dev/null || true)" != "amd64" ]]; then
dokku_log_warn "Detected linux/amd64 image, forcing --platform=linux/amd64"
DOCKER_ARGS+=" --platform=linux/amd64"
fi
# shellcheck disable=SC2124
DOCKER_ARGS+=" --label=com.dokku.container-type=$PROCESS_TYPE"
DOCKER_ARGS+=" --label=com.dokku.app-name=$APP"