refactor: add global docker build and run args

This reduces duplication and allows users to rely on global arguments to generate most labels needed.

The 'commit' command cannot have global arguments because the whitespace within the label change breaks string-based interpolation, and shell arrays cannot be exported.
This commit is contained in:
Jose Diaz-Gonzalez
2019-07-19 15:50:55 -04:00
parent 193e40b4c3
commit 6836e56b24
15 changed files with 59 additions and 45 deletions

View File

@@ -135,4 +135,3 @@ case "$1" in
exit $?
;;
esac

View File

@@ -30,7 +30,8 @@ teardown() {
assert_success
CID=$(docker ps -a -q -f "ancestor=dokku/${TEST_APP}" -f "label=dokku_phase_script=postdeploy")
IMAGE_ID=$(docker commit $CID dokku-test/${TEST_APP})
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=$TEST_APP")
IMAGE_ID=$(docker commit "${DOCKER_COMMIT_LABEL_ARGS[@]}" $CID dokku-test/${TEST_APP})
run /bin/bash -c "docker run -ti $IMAGE_ID ls /app/postdeploy.test"
echo "output: $output"
echo "status: $status"