aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManuel Rüger <mrueg@gentoo.org>2017-04-24 17:11:23 +0200
committerManuel Rüger <manuel@rueg.eu>2017-05-07 16:50:28 +0200
commit64f150f16c0eb0f549dd8381914f7b7e1cdd195b (patch)
tree9c1f6dbbb31abad3d45ddac2664b24cfbf8ef264 /build.sh
parentMerge pull request #36 from mrueg/rc_sys (diff)
downloaddocker-images-64f150f16c0eb0f549dd8381914f7b7e1cdd195b.tar.gz
docker-images-64f150f16c0eb0f549dd8381914f7b7e1cdd195b.tar.bz2
docker-images-64f150f16c0eb0f549dd8381914f7b7e1cdd195b.zip
Utilize multi-stage builds
* Multi-Stage builds (docker-engine >=17.05.0 required) * Bootstrap image changed from busybox to alpine * Verifies the GPG signatures during bootstrap * Single build.sh to define builds via a TARGET environment variable * Add x86-hardened * Travis CI integration
Diffstat (limited to 'build.sh')
-rwxr-xr-xbuild.sh32
1 files changed, 32 insertions, 0 deletions
diff --git a/build.sh b/build.sh
new file mode 100755
index 0000000..233a802
--- /dev/null
+++ b/build.sh
@@ -0,0 +1,32 @@
+#!/bin/bash
+
+# Used to create Gentoo stage3 and portage containers simply by specifying a
+# TARGET env variable.
+# Example usage: TARGET=stage-amd64 ./build.sh
+
+
+# Split the TARGET variable into three elements separated by hyphens
+IFS=- read -r NAME ARCH SUFFIX <<< "${TARGET}"
+
+# Ensure upstream directories for stage3-amd64-hardened+nomultilib work
+SUFFIX=${SUFFIX/-/+}
+
+VERSION=${VERSION:-$(date -u +%Y%m%d)}
+
+ORG=${ORG:-gentoo}
+
+# x86 requires the i686 subfolder
+if [[ "${ARCH}" == "x86" ]]; then
+ MICROARCH="i686"
+ BOOTSTRAP="multiarch/alpine:x86-v3.5"
+else
+ MICROARCH="${ARCH}"
+fi
+
+# Prefix the suffix with a hyphen to make sure the URL works
+if [[ -n "${SUFFIX}" ]]; then
+ SUFFIX="-${SUFFIX}"
+fi
+
+docker build --build-arg ARCH="${ARCH}" --build-arg MICROARCH="${MICROARCH}" --build-arg BOOTSTRAP="${BOOTSTRAP}" --build-arg SUFFIX="${SUFFIX}" -t "${ORG}/${TARGET}:${VERSION}" -f "${NAME}.Dockerfile" .
+docker tag "${ORG}/${TARGET}:${VERSION}" "${ORG}/${TARGET}:latest"