Skip to content

Commit 6b35bf5

Browse files
committed
feat: properly label intermediate containers for later cleanup
Dokku 0.18.0 requires new labels for cleanup to work properly, so we need to inject them on all docker commit commands. Also use DOCKER_BIN environment variable so that it may be swapped out via runtime configuration.
1 parent 66a1fe7 commit 6b35bf5

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

pre-build-buildpack

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env bash
22
set -eo pipefail
33
[[ $DOKKU_TRACE ]] && set -x
4+
export DOCKER_BIN=${DOCKER_BIN:="docker"}
45

56
hook-apt-pre-build-buildpack() {
67
declare APP="$1"
@@ -56,10 +57,11 @@ sleep 1 # wait so that docker run has not exited before docker attach
5657
EOF
5758
)
5859
CID=$(docker run -d "$IMAGE" /bin/bash -e -c "$COMMAND")
59-
#enable logs
60-
docker attach "$CID"
61-
test "$(docker wait "$CID")" -eq 0
62-
docker commit "$CID" "$IMAGE" >/dev/null
60+
local DOCKER_COMMIT_LABEL_ARGS=("--change" "LABEL org.label-schema.schema-version=1.0" "--change" "LABEL org.label-schema.vendor=dokku" "--change" "LABEL com.dokku.app-name=$APP" "--change" "LABEL $DOKKU_CONTAINER_LABEL")
61+
62+
"$DOCKER_BIN" attach "$CID"
63+
test "$("$DOCKER_BIN" wait "$CID")" -eq 0
64+
"$DOCKER_BIN" commit "${DOCKER_COMMIT_LABEL_ARGS[@]}" "$CID" "$IMAGE" >/dev/null
6365
}
6466

6567
hook-apt-pre-build-buildpack "$@"

0 commit comments

Comments
 (0)