-
Notifications
You must be signed in to change notification settings - Fork 692
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
195 additions
and
213 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,16 @@ | ||
#!/bin/bash | ||
|
||
set -ex | ||
|
||
# Setup tools and load utils | ||
TO_JSON_TOOL="%{to_json_tool}" | ||
source %{util_script} | ||
|
||
# Resolve the docker tool path | ||
DOCKER="%{docker_tool_path}" | ||
DOCKER_FLAGS="%{docker_flags}" | ||
|
||
if [[ -z "$DOCKER" ]]; then | ||
echo >&2 "error: docker not found; do you need to manually configure the docker toolchain?" | ||
exit 1 | ||
fi | ||
|
||
# Load the image and remember its name | ||
image_id=$(%{image_id_extractor_path} %{image_tar}) | ||
$DOCKER $DOCKER_FLAGS load -i %{image_tar} | ||
|
||
id=$($DOCKER $DOCKER_FLAGS run -d %{docker_run_flags} $image_id %{commands}) | ||
# Actually wait for the container to finish running its commands | ||
retcode=$($DOCKER $DOCKER_FLAGS wait $id) | ||
# Trigger a failure if the run had a non-zero exit status | ||
if [ $retcode != 0 ]; then | ||
$DOCKER $DOCKER_FLAGS logs $id && false | ||
fi | ||
|
||
reset_cmd $image_id $id %{output_image} | ||
config=$(< %{commit_base_config}) | ||
cmd='["/bin/sh", "-c", "/bin/bash"]' | ||
regex='\"Cmd\" ?: ?(\[[^]]*\])' | ||
if [[ config =~ regex ]]; then | ||
cmd=${BASH_REMATCH[1]} | ||
fi | ||
$DOCKER $DOCKER_FLAGS commit -c "CMD $cmd" $id %{output_image} | ||
$DOCKER $DOCKER_FLAGS save %{output_image} -o %{output_tar} | ||
$DOCKER $DOCKER_FLAGS rm $id | ||
$DOCKER $DOCKER_FLAGS rm $id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.