diff --git a/Dockerfile b/Dockerfile index 4ee1a8b..8d77935 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,3 +7,12 @@ RUN /install_deps.sh # Pre-install those here for faster local builds. RUN CFLAGS="-DPR_SET_CHILD_SUBREAPER=36 -DPR_GET_CHILD_SUBREAPER=37" pip install psutil python-prctl bitmap + +ARG ARCH_NATIVE +ARG CC + +# Persist ARGs into the image + +ENV ARCH_SUFFIX="$ARCH_SUFFIX" \ + ARCH_NATIVE="$ARCH_NATIVE" \ + CC="$CC" diff --git a/ddist.sh b/ddist.sh index 0625399..eed7d46 100755 --- a/ddist.sh +++ b/ddist.sh @@ -2,35 +2,46 @@ set -o errexit set -o nounset -if [[ "$#" != 1 ]]; then - echo "Usage: $0 ARCH_SUFFIX" - exit 1 -fi -suffix="$1" - REL_HERE=$(dirname "${BASH_SOURCE}") HERE=$(cd "${REL_HERE}"; pwd) -IMG="tini-build-${suffix}" -SRC="/tini" +IMG="tini-build" + +if [[ -n "${ARCH_SUFFIX-}" ]]; then + IMG="${IMG}_${ARCH_SUFFIX}" +fi + +if [[ -n "${ARCH_NATIVE-}" ]]; then + IMG="${IMG}_native" +fi + +if [[ -n "${CC-}" ]]; then + IMG="${IMG}_${CC}" +fi # Cleanup the build dir rm -f "${HERE}/dist"/* # Create the build image -docker build --build-arg "ARCH_SUFFIX=${suffix}" -t "${IMG}" . +echo "build: ${IMG}" + +docker build \ + --build-arg "ARCH_SUFFIX=${ARCH_SUFFIX-}" \ + --build-arg "ARCH_NATIVE=${ARCH_NATIVE-}" \ + --build-arg "CC=${CC-gcc}" \ + -t "${IMG}" \ + . + +# Build new Tini +SRC="/tini" -# Run test without subreaper support, don't copy build files here docker run -it --rm \ --volume="${HERE}:${SRC}" \ -e BUILD_DIR=/tmp/tini-build \ -e SOURCE_DIR="${SRC}" \ - -e FORCE_SUBREAPER="${FORCE_SUBREAPER:="1"}" \ - -e GPG_PASSPHRASE="${GPG_PASSPHRASE:=}" \ - -e CC="${CC:=gcc}" \ + -e FORCE_SUBREAPER="${FORCE_SUBREAPER-1}" \ + -e GPG_PASSPHRASE="${GPG_PASSPHRASE-}" \ -e CFLAGS="${CFLAGS-}" \ - -e ARCH_NATIVE="${ARCH_NATIVE-}" \ - -e ARCH_SUFFIX="${suffix}" \ -e MINIMAL="${MINIMAL-}" \ -u "$(id -u):$(id -g)" \ "${IMG}" "${SRC}/ci/run_build.sh"