-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: use docker_squash lib, not docker-squash script
The docker-squash script used to print the squashed <image id> on stderr, but recently it was changed so the image id is printed to stdout. To be able to parse image id from both docker_squash versions (before and after this change), we'd have to have some ugly if-fork to detect the docker_squash version (or play with FD redirection). So rather let's do as upstream suggested in [1] and use the docker_squash library directly. Also add a simple CI test for the ./squash.py file. [1] goldmann/docker-squash#145 Fixes: #101
- Loading branch information
Showing
5 changed files
with
56 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#! /bin/python | ||
|
||
import sys | ||
import logging | ||
from platform import python_version | ||
|
||
try: | ||
from docker_squash import squash | ||
except ImportError: | ||
logging.fatal("please install 'docker_squash' for Python {0}".format(python_version())) | ||
sys.exit(1) | ||
|
||
|
||
if __name__ == "__main__": | ||
if len(sys.argv) != 3: | ||
logging.fatal("%s: %s", sys.argv[0], msg) | ||
sys.exit(1) | ||
|
||
print(squash.Squash( | ||
log=logging.getLogger(), | ||
image=sys.argv[1], | ||
from_layer=sys.argv[2]).run() | ||
) |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
Dockerfile |
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#! /bin/sh | ||
|
||
set -e | ||
|
||
origin=busybox | ||
squash=$(dirname "$(readlink -f "$0")")/../../squash.py | ||
cd "$(dirname "$0")" | ||
|
||
cat > Dockerfile <<EOF | ||
FROM $origin | ||
ENV test=test | ||
CMD /bin/echo test | ||
EOF | ||
out=`docker build . | awk '/Successfully built/{print $NF}'` | ||
echo "$out" | ||
squashed=$("${PYTHON-python3}" "$squash" "$out" "$origin") | ||
output=$(docker run --rm $squashed) | ||
test "$output" = "test" |