diff --git a/buildfromtarball/Dockerfile b/buildfromtarball/Dockerfile new file mode 100644 index 0000000..46734d5 --- /dev/null +++ b/buildfromtarball/Dockerfile @@ -0,0 +1,11 @@ +FROM docker + +RUN apk install --no-cache \ + bash \ + ca-certificates \ + curl \ + tar + +COPY build.sh /usr/local/bin/build + +ENTRYPOINT ["build"] diff --git a/buildfromtarball/build.sh b/buildfromtarball/build.sh new file mode 100755 index 0000000..f543ad9 --- /dev/null +++ b/buildfromtarball/build.sh @@ -0,0 +1,22 @@ +#!/bin/bash +set -e +set -o pipefail +set -x + +tarball=$1 +image=$2 + +volume=/build + +mkdir -p "$build" + +curl --fail --silent --show-error --location "$tarball" | tar xvz --strip=1 -C %s 2>/dev/null) || (echo ""; printf "ERROR: %%s\n" "Could not prepare an image." "Please verify that $tarball is still available and is publicly accessible."; exit 1) + +# Try to pull the image. +docker pull "$image" || true + +cd "$build" + +docker build --cache-from "$image" -t "$image" . + +docker push "$image"