Minimise docker layers

This commit is contained in:
Simon Bruder 2019-11-01 16:28:18 +00:00 committed by Jakob Lechner
parent 3e89556ae6
commit aedcc9d9bc
6 changed files with 61 additions and 90 deletions

View file

@ -46,7 +46,4 @@ RUN gpg --import /usr/local/share/hashicorp.asc \
WORKDIR /workdir
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
# vim: ts=4 sw=4 sts=4 noet:

View file

@ -1,66 +0,0 @@
#!/bin/sh
set -e
make_torrent() {
(cd /images
if [ "$NAME" = "" ]; then
# remove file extension
NAME="$(echo "$1" | sed 's/\.[^.]*//')"
fi
if [ "$WEBSEED" = "" ]; then
echo '$WEBSEED not provided' >&2
exit 1
fi
if [ "$ANNOUNCE" = "" ]; then
echo '$ANNOUNCE not provided' >&2
exit 1
fi
TORRENT_FILE="$NAME.torrent"
WEBSEED_URL="$WEBSEED/$1"
if [ -e "$TORRENT_FILE" ]; then rm "$TORRENT_FILE"; fi
mktorrent \
-n "$NAME" \
-a "$ANNOUNCE" \
-o "$TORRENT_FILE" \
-l 22 \
-w "$WEBSEED_URL" \
"$1"
if [ "$user" != "" ] && [ "$group" != "" ]; then
chown "$user:$group" "$TORRENT_FILE"
fi
)
}
run_packer() {
packer build "$NAME.json"
if [ "$user" != "" ] && [ "$group" != "" ]; then
chown $user:$group "/images/${NAME}."*
fi
}
NAME="$1"
if [ "$NAME" = "" ]; then
echo 'no name supplied, stopping.' >&2
exit 1
fi
export NAME
if [ -z "$TASK" ] || [ "$TASK" == "packer" ]; then
run_packer
fi
if [ -z "$TASK" ] || [ "$TASK" == "torrent" ]; then
make_torrent "$NAME.squashfs"
fi
if [ "$TASK" == "ansible" ]; then
cd /ansible
/usr/bin/ansible-playbook "$@"
fi