Clean up multi-arch builds a bit

- `ARCH_SUFFIX` should not be passed at runtime: it's already passed as
  a build argument, and it's consumed during the build (so it's too late
  to change it at runtime).
- For consistency, pass `ARCH_NATIVE` and `CC` similarly at build time
  as well: passing `CC` and `ARCH_SUFFIX` at different times is
  particularly error-prone.
- Accept all parameters to `ddist.sh` via environment variables. It
  doesn't make sense to accept exclusively `ARCH_SUFFIX` as a positional
  argument when `ARCH_SUFFIX` alone doesn't accomplish anything (i.e.
  you also need `CC`).

TODO: `CC` should be derived from `ARCH_SUFFIX` in the first place.
pull/98/head
Thomas Orozco 7 years ago committed by Tianon Gravi
parent 7be42da42b
commit a77c1fd423
  1. 9
      Dockerfile
  2. 41
      ddist.sh

@ -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"

@ -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"

Loading…
Cancel
Save