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
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
-rw-r--r--.travis.yml34
-rw-r--r--README.md39
-rw-r--r--amd64-hardened-nomultilib/Dockerfile14
-rwxr-xr-xamd64-hardened-nomultilib/build.sh47
-rw-r--r--amd64-hardened/Dockerfile14
-rwxr-xr-xamd64-hardened/build.sh47
-rw-r--r--amd64-nomultilib/Dockerfile14
-rwxr-xr-xamd64-nomultilib/build.sh47
-rw-r--r--amd64/.dockerignore8
-rw-r--r--amd64/Dockerfile14
-rwxr-xr-xamd64/build.sh47
-rwxr-xr-xbuild.sh32
-rw-r--r--portage.Dockerfile32
-rw-r--r--portage/Dockerfile10
-rw-r--r--stage3.Dockerfile39
-rw-r--r--x86/.dockerignore7
-rw-r--r--x86/Dockerfile19
-rwxr-xr-xx86/build.sh48
18 files changed, 166 insertions, 346 deletions
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..1d7d7fe
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,34 @@
+sudo: required
+services: docker
+language: bash
+env:
+ global:
+ - ORG=gentoo
+ matrix:
+ - TARGET=portage
+ - TARGET=stage3-amd64
+ - TARGET=stage3-amd64-hardened
+ - TARGET=stage3-amd64-hardened-nomultilib
+ - TARGET=stage3-amd64-nomultilib
+ - TARGET=stage3-x86
+ - TARGET=stage3-x86-hardened
+
+before_install:
+ # Install docker 17.05.0 or later
+ - sudo apt-get update -qq
+ - sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-engine
+script:
+ - VERSION="$(date -u +%Y%m%d)"
+ - sudo ./build.sh
+ - if [[ "${TARGET}" == stage* ]]; then
+ sudo docker run -it --rm ${ORG}/${TARGET}:${VERSION} /bin/bash -c "emerge --info" ;
+ fi
+
+# Travis is set up to push daily to dockerhub
+after_success:
+ - if [[ "${TRAVIS_PULL_REQUEST_BRANCH:-${TRAVIS_BRANCH}}" == "master" && "${TRAVIS_EVENT_TYPE}" == "cron" ]]; then
+ VERSION=$(date -u +%Y%m%d);
+ docker login -u="${DOCKER_USERNAME}" -p="${DOCKER_PASSWORD}";
+ docker push "${ORG}/${TARGET}:latest";
+ docker push "${ORG}/${TARGET}:${VERSION}";
+ fi
diff --git a/README.md b/README.md
index 4f4c79c..f2c6f4e 100644
--- a/README.md
+++ b/README.md
@@ -1,14 +1,16 @@
# Gentoo Docker Images
+[![Build Status](https://travis-ci.org/gentoo/gentoo-docker-images.svg?branch=master)](https://travis-ci.org/gentoo/gentoo-docker-images)
+
A collection of Dockerfiles for generating Gentoo docker images.
These images are intended to be created automatically by
-[docker hub](https://hub.docker.com/u/gentoo/) and include basic
-stage3 images and an image usable as a `/usr/portage` volume.
+a travis cron job and pushed to [docker hub](https://hub.docker.com/u/gentoo/).
+This repository include basic stage3 images and an image usable as a `/usr/portage` volume
# DockerHub
-https://registry.hub.docker.com/u/gentoo/stage3-amd64/
+https://hub.docker.com/u/gentoo/
## Inventory
@@ -17,6 +19,23 @@ https://registry.hub.docker.com/u/gentoo/stage3-amd64/
* stage3-amd64
* stage3-amd64-hardened
* stage3-amd64-nomultilib
+ * stage3-amd64-hardened-nomultilib
+ * stage3-x86
+ * stage3-x86-hardened
+
+# Building the containers
+
+The containers are created using a multi-stage build, which requires docker-17.05.0 or later.
+The container being built is defined by the TARGET environment variable:
+
+`` TARGET=stage-amd64 ./build.sh ``
+
+# Using the portage container as a data volume
+
+```
+docker create -v /usr/portage --name myportagesnapshot gentoo/portage:latest /bin/true
+docker run --volumes-from myportagesnapshot gentoo/stage-amd64:latest /bin/bash
+```
# Contributing
@@ -29,11 +48,11 @@ methods:
## Policy
-* use topic branches (i.e. foo) and fix branches (i.e. fix/foo) when submitting
+* Use topic branches (i.e. foo) and fix branches (i.e. fix/foo) when submitting
pull requests
-* make meaningful commits ideally with the following form:
- * subject line–what this commit does
- * blank line
- * body–why this commit is necessary or desired
-* pull requests should not include merge commits
-* use amend and rebase to fix commits after a pull request has been submitted
+* Make meaningful commits ideally with the following form:
+ * Subject line–what this commit does
+ * Blank line
+ * Body–why this commit is necessary or desired
+* Pull requests should not include merge commits
+* Use amend and rebase to fix commits after a pull request has been submitted
diff --git a/amd64-hardened-nomultilib/Dockerfile b/amd64-hardened-nomultilib/Dockerfile
deleted file mode 100644
index c5c5687..0000000
--- a/amd64-hardened-nomultilib/Dockerfile
+++ /dev/null
@@ -1,14 +0,0 @@
-FROM busybox
-
-MAINTAINER Gentoo Docker Team
-
-# This one should be present by running the build.sh script
-ADD build.sh /
-
-RUN /build.sh amd64 x86_64 -hardened+nomultilib
-
-# Setup the rc_sys
-RUN sed -e 's/#rc_sys=""/rc_sys="docker"/g' -i /etc/rc.conf
-
-# By default, UTC system
-RUN echo 'UTC' > /etc/timezone
diff --git a/amd64-hardened-nomultilib/build.sh b/amd64-hardened-nomultilib/build.sh
deleted file mode 100755
index ea64118..0000000
--- a/amd64-hardened-nomultilib/build.sh
+++ /dev/null
@@ -1,47 +0,0 @@
-# First param is package tarball, 2nd is the *.DIGEST file
-VerifyShaOfStage3()
-{
- test_sum=$(awk -v myvar="$1" '$2==myvar {for(i=1; i<=1; i++) { print $1; exit}}' $2)
- calculated_sum=$(sha512sum $1 | awk '{print $1}' -)
- if [[ "$test_sum" == "$calculated_sum" ]]; then
- return 0
- else
- return 1
- fi
-}
-
-suffix=$3 # e.g. -hardened
-arch=$1
-dist="http://distfiles.gentoo.org/releases/${arch}/autobuilds/"
-stage3path="$(wget -q -O- ${dist}/latest-stage3-${arch}${suffix}.txt | tail -n 1 | cut -f 1 -d ' ')"
-stage3="$(basename ${stage3path})"
-
-# Create working directory, keep a copy of busybox handy
-mkdir newWorldOrder; cd newWorldOrder
-cp /bin/busybox .
-
-echo "Downloading and extracting ${stage3path}..."
-wget -q -c "${dist}/${stage3path}" "${dist}/${stage3path}.DIGESTS"
-if VerifyShaOfStage3 $stage3 "${stage3}.DIGESTS"; then
- echo "DIGEST sum is okey";
-else
- echo "DIGEST sum is NOT okey";
- return 1;
-fi
-bunzip2 -c ${stage3} | tar --exclude "./etc/hosts" --exclude "./sys/*" -xf -
-/newWorldOrder/busybox rm -f $stage3
-
-echo "Installing stage 3"
-/newWorldOrder/busybox rm -rf /lib* /usr /var /bin /sbin /opt /mnt /media /root /home /run /tmp
-/newWorldOrder/busybox cp -fRap lib* /
-/newWorldOrder/busybox cp -fRap bin boot home media mnt opt root run sbin tmp usr var /
-/newWorldOrder/busybox cp -fRap etc/* /etc/
-
-# Cleaning
-cd /
-/newWorldOrder/busybox rm -rf /newWorldOrder /build.sh /linuxrc
-
-# Say hello
-echo "Bootstrapped ${stage3path} into /:"
-ls --color -lah
-
diff --git a/amd64-hardened/Dockerfile b/amd64-hardened/Dockerfile
deleted file mode 100644
index bfde2bf..0000000
--- a/amd64-hardened/Dockerfile
+++ /dev/null
@@ -1,14 +0,0 @@
-FROM busybox
-
-MAINTAINER Gentoo Docker Team
-
-# This one should be present by running the build.sh script
-ADD build.sh /
-
-RUN /build.sh amd64 x86_64 -hardened
-
-# Setup the rc_sys
-RUN sed -e 's/#rc_sys=""/rc_sys="docker"/g' -i /etc/rc.conf
-
-# By default, UTC system
-RUN echo 'UTC' > /etc/timezone
diff --git a/amd64-hardened/build.sh b/amd64-hardened/build.sh
deleted file mode 100755
index ea64118..0000000
--- a/amd64-hardened/build.sh
+++ /dev/null
@@ -1,47 +0,0 @@
-# First param is package tarball, 2nd is the *.DIGEST file
-VerifyShaOfStage3()
-{
- test_sum=$(awk -v myvar="$1" '$2==myvar {for(i=1; i<=1; i++) { print $1; exit}}' $2)
- calculated_sum=$(sha512sum $1 | awk '{print $1}' -)
- if [[ "$test_sum" == "$calculated_sum" ]]; then
- return 0
- else
- return 1
- fi
-}
-
-suffix=$3 # e.g. -hardened
-arch=$1
-dist="http://distfiles.gentoo.org/releases/${arch}/autobuilds/"
-stage3path="$(wget -q -O- ${dist}/latest-stage3-${arch}${suffix}.txt | tail -n 1 | cut -f 1 -d ' ')"
-stage3="$(basename ${stage3path})"
-
-# Create working directory, keep a copy of busybox handy
-mkdir newWorldOrder; cd newWorldOrder
-cp /bin/busybox .
-
-echo "Downloading and extracting ${stage3path}..."
-wget -q -c "${dist}/${stage3path}" "${dist}/${stage3path}.DIGESTS"
-if VerifyShaOfStage3 $stage3 "${stage3}.DIGESTS"; then
- echo "DIGEST sum is okey";
-else
- echo "DIGEST sum is NOT okey";
- return 1;
-fi
-bunzip2 -c ${stage3} | tar --exclude "./etc/hosts" --exclude "./sys/*" -xf -
-/newWorldOrder/busybox rm -f $stage3
-
-echo "Installing stage 3"
-/newWorldOrder/busybox rm -rf /lib* /usr /var /bin /sbin /opt /mnt /media /root /home /run /tmp
-/newWorldOrder/busybox cp -fRap lib* /
-/newWorldOrder/busybox cp -fRap bin boot home media mnt opt root run sbin tmp usr var /
-/newWorldOrder/busybox cp -fRap etc/* /etc/
-
-# Cleaning
-cd /
-/newWorldOrder/busybox rm -rf /newWorldOrder /build.sh /linuxrc
-
-# Say hello
-echo "Bootstrapped ${stage3path} into /:"
-ls --color -lah
-
diff --git a/amd64-nomultilib/Dockerfile b/amd64-nomultilib/Dockerfile
deleted file mode 100644
index 11b811e..0000000
--- a/amd64-nomultilib/Dockerfile
+++ /dev/null
@@ -1,14 +0,0 @@
-FROM busybox
-
-MAINTAINER Gentoo Docker Team
-
-# This one should be present by running the build.sh script
-ADD build.sh /
-
-RUN /build.sh amd64 x86_64 -nomultilib
-
-# Setup the rc_sys
-RUN sed -e 's/#rc_sys=""/rc_sys="docker"/g' -i /etc/rc.conf
-
-# By default, UTC system
-RUN echo 'UTC' > /etc/timezone
diff --git a/amd64-nomultilib/build.sh b/amd64-nomultilib/build.sh
deleted file mode 100755
index ea64118..0000000
--- a/amd64-nomultilib/build.sh
+++ /dev/null
@@ -1,47 +0,0 @@
-# First param is package tarball, 2nd is the *.DIGEST file
-VerifyShaOfStage3()
-{
- test_sum=$(awk -v myvar="$1" '$2==myvar {for(i=1; i<=1; i++) { print $1; exit}}' $2)
- calculated_sum=$(sha512sum $1 | awk '{print $1}' -)
- if [[ "$test_sum" == "$calculated_sum" ]]; then
- return 0
- else
- return 1
- fi
-}
-
-suffix=$3 # e.g. -hardened
-arch=$1
-dist="http://distfiles.gentoo.org/releases/${arch}/autobuilds/"
-stage3path="$(wget -q -O- ${dist}/latest-stage3-${arch}${suffix}.txt | tail -n 1 | cut -f 1 -d ' ')"
-stage3="$(basename ${stage3path})"
-
-# Create working directory, keep a copy of busybox handy
-mkdir newWorldOrder; cd newWorldOrder
-cp /bin/busybox .
-
-echo "Downloading and extracting ${stage3path}..."
-wget -q -c "${dist}/${stage3path}" "${dist}/${stage3path}.DIGESTS"
-if VerifyShaOfStage3 $stage3 "${stage3}.DIGESTS"; then
- echo "DIGEST sum is okey";
-else
- echo "DIGEST sum is NOT okey";
- return 1;
-fi
-bunzip2 -c ${stage3} | tar --exclude "./etc/hosts" --exclude "./sys/*" -xf -
-/newWorldOrder/busybox rm -f $stage3
-
-echo "Installing stage 3"
-/newWorldOrder/busybox rm -rf /lib* /usr /var /bin /sbin /opt /mnt /media /root /home /run /tmp
-/newWorldOrder/busybox cp -fRap lib* /
-/newWorldOrder/busybox cp -fRap bin boot home media mnt opt root run sbin tmp usr var /
-/newWorldOrder/busybox cp -fRap etc/* /etc/
-
-# Cleaning
-cd /
-/newWorldOrder/busybox rm -rf /newWorldOrder /build.sh /linuxrc
-
-# Say hello
-echo "Bootstrapped ${stage3path} into /:"
-ls --color -lah
-
diff --git a/amd64/.dockerignore b/amd64/.dockerignore
deleted file mode 100644
index 942a04b..0000000
--- a/amd64/.dockerignore
+++ /dev/null
@@ -1,8 +0,0 @@
-*.bz2
-*.xz
-*.asc
-*.DIGESTS
-*.CONTENTS
-*.swp
-busybox-x86_64
-busybox
diff --git a/amd64/Dockerfile b/amd64/Dockerfile
deleted file mode 100644
index 374947c..0000000
--- a/amd64/Dockerfile
+++ /dev/null
@@ -1,14 +0,0 @@
-FROM busybox
-
-MAINTAINER Gentoo Docker Team
-
-# This one should be present by running the build.sh script
-ADD build.sh /
-
-RUN /build.sh amd64 x86_64
-
-# Setup the rc_sys
-RUN sed -e 's/#rc_sys=""/rc_sys="docker"/g' -i /etc/rc.conf
-
-# By default, UTC system
-RUN echo 'UTC' > /etc/timezone
diff --git a/amd64/build.sh b/amd64/build.sh
deleted file mode 100755
index ea64118..0000000
--- a/amd64/build.sh
+++ /dev/null
@@ -1,47 +0,0 @@
-# First param is package tarball, 2nd is the *.DIGEST file
-VerifyShaOfStage3()
-{
- test_sum=$(awk -v myvar="$1" '$2==myvar {for(i=1; i<=1; i++) { print $1; exit}}' $2)
- calculated_sum=$(sha512sum $1 | awk '{print $1}' -)
- if [[ "$test_sum" == "$calculated_sum" ]]; then
- return 0
- else
- return 1
- fi
-}
-
-suffix=$3 # e.g. -hardened
-arch=$1
-dist="http://distfiles.gentoo.org/releases/${arch}/autobuilds/"
-stage3path="$(wget -q -O- ${dist}/latest-stage3-${arch}${suffix}.txt | tail -n 1 | cut -f 1 -d ' ')"
-stage3="$(basename ${stage3path})"
-
-# Create working directory, keep a copy of busybox handy
-mkdir newWorldOrder; cd newWorldOrder
-cp /bin/busybox .
-
-echo "Downloading and extracting ${stage3path}..."
-wget -q -c "${dist}/${stage3path}" "${dist}/${stage3path}.DIGESTS"
-if VerifyShaOfStage3 $stage3 "${stage3}.DIGESTS"; then
- echo "DIGEST sum is okey";
-else
- echo "DIGEST sum is NOT okey";
- return 1;
-fi
-bunzip2 -c ${stage3} | tar --exclude "./etc/hosts" --exclude "./sys/*" -xf -
-/newWorldOrder/busybox rm -f $stage3
-
-echo "Installing stage 3"
-/newWorldOrder/busybox rm -rf /lib* /usr /var /bin /sbin /opt /mnt /media /root /home /run /tmp
-/newWorldOrder/busybox cp -fRap lib* /
-/newWorldOrder/busybox cp -fRap bin boot home media mnt opt root run sbin tmp usr var /
-/newWorldOrder/busybox cp -fRap etc/* /etc/
-
-# Cleaning
-cd /
-/newWorldOrder/busybox rm -rf /newWorldOrder /build.sh /linuxrc
-
-# Say hello
-echo "Bootstrapped ${stage3path} into /:"
-ls --color -lah
-
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"
diff --git a/portage.Dockerfile b/portage.Dockerfile
new file mode 100644
index 0000000..19de08e
--- /dev/null
+++ b/portage.Dockerfile
@@ -0,0 +1,32 @@
+# This Dockerfile creates a portage snapshot that can be mounted as a
+# container volume. It utilizes a multi-stage build and requires
+# docker-17.05.0 or later. It fetches a daily snapshot from the official
+# sources and verifies its checksum as well as its gpg signature.
+
+# As gpg keyservers sometimes are unreliable, we use multiple gpg server pools
+# to fetch the signing key.
+
+FROM alpine:3.5 as builder
+
+WORKDIR /portage
+
+ARG SNAPSHOT="portage-latest.tar.xz"
+ARG DIST="http://distfiles.gentoo.org/snapshots"
+ARG SIGNING_KEY="0xEC590EEAC9189250"
+
+RUN apk add --no-cache gnupg tar wget xz \
+ && wget -q -c "${DIST}/${SNAPSHOT}" "${DIST}/${SNAPSHOT}.gpgsig" "${DIST}/${SNAPSHOT}.md5sum" \
+ && gpg --keyserver hkps.pool.sks-keyservers.net --recv-keys ${SIGNING_KEY} \
+ && gpg --verify "${SNAPSHOT}.gpgsig" "${SNAPSHOT}" \
+ || gpg --keyserver keys.gnupg.net --recv-keys ${SIGNING_KEY} \
+ || gpg --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys ${SIGNING_KEY} \
+ && md5sum -c ${SNAPSHOT}.md5sum \
+ && mkdir -p usr/portage/distfiles usr/portage/packages \
+ && tar xJpf ${SNAPSHOT} -C usr \
+ && rm ${SNAPSHOT} ${SNAPSHOT}.gpgsig ${SNAPSHOT}.md5sum
+
+FROM scratch
+
+WORKDIR /
+
+COPY --from=builder /portage/ /
diff --git a/portage/Dockerfile b/portage/Dockerfile
deleted file mode 100644
index 85d7f3b..0000000
--- a/portage/Dockerfile
+++ /dev/null
@@ -1,10 +0,0 @@
-FROM busybox:latest
-MAINTAINER Gentoo Container Team <containers@gentoo.org>
-
-ADD http://distfiles.gentoo.org/snapshots/portage-latest.tar.bz2 /
-
-RUN mkdir -p /usr
-RUN bzcat /portage-latest.tar.bz2 | tar -xf - -C /usr
-RUN mkdir -p /usr/portage/distfiles /usr/portage/metadata /usr/portage/packages
-
-VOLUME /usr/portage
diff --git a/stage3.Dockerfile b/stage3.Dockerfile
new file mode 100644
index 0000000..20fdf32
--- /dev/null
+++ b/stage3.Dockerfile
@@ -0,0 +1,39 @@
+# This Dockerfile creates a gentoo stage3 container image. By default it
+# creates a stage3-amd64 image. It utilizes a multi-stage build and requires
+# docker-17.05.0 or later. It fetches a daily snapshot from the official
+# sources and verifies its checksum as well as its gpg signature.
+
+# As gpg keyservers sometimes are unreliable, we use multiple gpg server pools
+# to fetch the signing key.
+
+
+FROM ${BOOTSTRAP:-alpine:3.5} as builder
+
+WORKDIR /gentoo
+
+ARG ARCH=amd64
+ARG MICROARCH=amd64
+ARG SUFFIX
+ARG DIST="http://distfiles.gentoo.org/releases/${ARCH}/autobuilds/"
+ARG SIGNING_KEY="0xBB572E0E2D182910"
+
+RUN echo "Building Gentoo Container image for ${ARCH} ${SUFFIX} fetching from ${DIST}" \
+ && apk --no-cache add gnupg tar wget \
+ && STAGE3PATH="$(wget -q -O- "${DIST}/latest-stage3-${MICROARCH}${SUFFIX}.txt" | tail -n 1 | cut -f 1 -d ' ')" \
+ && STAGE3="$(basename ${STAGE3PATH})" \
+ && wget -q -c "${DIST}/${STAGE3PATH}" "${DIST}/${STAGE3PATH}.CONTENTS" "${DIST}/${STAGE3PATH}.DIGESTS.asc" \
+ && gpg --keyserver hkps.pool.sks-keyservers.net --recv-keys ${SIGNING_KEY} \
+ || gpg --keyserver keys.gnupg.net --recv-keys ${SIGNING_KEY} \
+ || gpg --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys ${SIGNING_KEY} \
+ && gpg --verify "${STAGE3}.DIGESTS.asc" \
+ && awk '/# SHA512 HASH/{getline; print}' ${STAGE3}.DIGESTS.asc | sha512sum -c \
+ && tar xjpf "${STAGE3}" --xattrs --numeric-owner \
+ && sed -i -e 's/#rc_sys=""/rc_sys="docker"/g' etc/rc.conf \
+ && echo 'UTC' > etc/timezone \
+ && rm ${STAGE3}.DIGESTS.asc ${STAGE3}.CONTENTS ${STAGE3}
+
+FROM scratch
+
+WORKDIR /
+COPY --from=builder /gentoo/ /
+CMD ["/bin/bash"]
diff --git a/x86/.dockerignore b/x86/.dockerignore
deleted file mode 100644
index 2302238..0000000
--- a/x86/.dockerignore
+++ /dev/null
@@ -1,7 +0,0 @@
-*.bz2
-*.xz
-*.asc
-*.DIGESTS
-*.CONTENTS
-*.swp
-busybox*
diff --git a/x86/Dockerfile b/x86/Dockerfile
deleted file mode 100644
index 835c5b8..0000000
--- a/x86/Dockerfile
+++ /dev/null
@@ -1,19 +0,0 @@
-FROM 32bit/debian:jessie
-
-MAINTAINER Gentoo Docker Team
-
-#ADD http://www.busybox.net/downloads/binaries/latest/busybox-i686 /busybox
-
-# This one should be present by running the build.sh script
-ADD build.sh /
-
-RUN apt-get update && apt-get install -y \
- wget bzip2
-
-RUN /build.sh x86 i686
-
-# Setup the rc_sys
-RUN sed -e 's/#rc_sys=""/rc_sys="docker"/g' -i /etc/rc.conf
-
-# By default, UTC system
-RUN echo 'UTC' > /etc/timezone
diff --git a/x86/build.sh b/x86/build.sh
deleted file mode 100755
index 4c23847..0000000
--- a/x86/build.sh
+++ /dev/null
@@ -1,48 +0,0 @@
-# First param is package tarball, 2nd is the *.DIGEST file
-VerifyShaOfStage3()
-{
- test_sum=$(awk -v myvar="$1" '$2==myvar {for(i=1; i<=1; i++) { print $1; exit}}' $2)
- calculated_sum=$(sha512sum $1 | awk '{print $1}' -)
- if [[ "$test_sum" == "$calculated_sum" ]]; then
- return 0
- else
- return 1
- fi
-}
-
-suffix=$3 # e.g. -hardened
-arch=$1
-busybox_version=$2
-dist="http://distfiles.gentoo.org/releases/${arch}/autobuilds/"
-stage3path="$(wget -q -O- ${dist}/latest-stage3-${busybox_version}${suffix}.txt | tail -n 1 | cut -f 1 -d ' ')"
-stage3="$(basename ${stage3path})"
-
-# Create working directory, keep a copy of busybox handy
-mkdir newWorldOrder; cd newWorldOrder
-cp /bin/busybox .
-
-echo "Downloading and extracting ${stage3path}..."
-wget -q -c "${dist}/${stage3path}" "${dist}/${stage3path}.DIGESTS"
-if VerifyShaOfStage3 $stage3 "${stage3}.DIGESTS"; then
- echo "DIGEST sum is okey";
-else
- echo "DIGEST sum is NOT okey";
- return 1;
-fi
-bunzip2 -c ${stage3} | tar --exclude "./etc/hosts" --exclude "./sys/*" -xf -
-/newWorldOrder/busybox rm -f $stage3
-
-echo "Installing stage 3"
-/newWorldOrder/busybox rm -rf /lib* /usr /var /bin /sbin /opt /mnt /media /root /home /run /tmp
-/newWorldOrder/busybox cp -fRap lib* /
-/newWorldOrder/busybox cp -fRap bin boot home media mnt opt root run sbin tmp usr var /
-/newWorldOrder/busybox cp -fRap etc/* /etc/
-
-# Cleaning
-cd /
-/newWorldOrder/busybox rm -rf /newWorldOrder /build.sh /linuxrc
-
-# Say hello
-echo "Bootstrapped ${stage3path} into /:"
-ls --color -lah
-