Browse Source

Merge pull request #100 from mirzak/split-docker-v2

parameterize target architecture when creating Docker container
1.2.x
Mirza Krak 6 years ago
committed by GitHub
parent
commit
c0cab4c664
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 22
      Dockerfile
  2. 12
      docker-build

22
Dockerfile

@ -28,7 +28,9 @@ RUN apt-get update && apt-get install -y \
# to download mender-artifact
wget \
# to download mender-convert and U-Boot sources
git
git \
# for arm64 support
gcc-aarch64-linux-gnu
# Disable sanity checks made by mtools. These checks reject copy/paste operations on converted disk images.
RUN echo "mtools_skip_check=1" >> $HOME/.mtoolsrc
@ -61,13 +63,25 @@ RUN go get -d github.com/mendersoftware/mender
WORKDIR $GOPATH/src/github.com/mendersoftware/mender
RUN git checkout $MENDER_CLIENT_VERSION
ENV CC "arm-buildroot-linux-gnueabihf-gcc"
# Toolchain configuration
ARG toolchain_host
RUN test -n "$toolchain_host" || (echo "Argument 'toolchain_host' is mandatory." && exit 1)
ENV TOOLCHAIN_HOST=${toolchain_host}
ARG go_flags
RUN test -n "$go_flags" || (echo "Argument 'go_flags' is mandatory." && exit 1)
ENV GO_FLAGS=$go_flags
RUN test -n "$mender_client_version" || (echo "Argument 'mender_client_version' is mandatory." && exit 1)
ENV MENDER_CLIENT_VERSION=$mender_client_version
ENV CC "${TOOLCHAIN_HOST}-gcc"
# Build liblzma from source
RUN wget -q https://tukaani.org/xz/xz-5.2.4.tar.gz \
&& tar -C /root -xzf xz-5.2.4.tar.gz \
&& cd /root/xz-5.2.4 \
&& ./configure --host=arm-buildroot-linux-gnueabihf --prefix=/root/xz-5.2.4/install \
&& ./configure --host=${TOOLCHAIN_HOST} --prefix=/root/xz-5.2.4/install \
&& make \
&& make install
@ -79,7 +93,7 @@ RUN env CGO_ENABLED=1 \
CGO_LDFLAGS="-L${LIBLZMA_INSTALL_PATH}/lib" \
CC=$CC \
GOOS=linux \
GOARM=6 GOARCH=arm make build
${GO_FLAGS} make build
# allow us to keep original PATH variables when sudoing
RUN echo "Defaults secure_path=\"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:$PATH\"" > /etc/sudoers.d/secure_path_override

12
docker-build

@ -6,4 +6,14 @@ IMAGE_NAME=mender-convert
MENDER_CLIENT_VERSION="2.0.0"
docker build . -t ${IMAGE_NAME} --build-arg mender_client_version=${MENDER_CLIENT_VERSION}
DOCKER_ARGS="--build-arg mender_client_version=${MENDER_CLIENT_VERSION}"
if [ "$1" = "arm64" ]; then
DOCKER_ARGS="${DOCKER_ARGS} --build-arg toolchain_host=aarch64-linux-gnu"
DOCKER_ARGS="${DOCKER_ARGS} --build-arg go_flags=GOARCH=arm64"
else
DOCKER_ARGS="${DOCKER_ARGS} --build-arg toolchain_host=arm-buildroot-linux-gnueabihf"
DOCKER_ARGS="${DOCKER_ARGS} --build-arg go_flags=\"GOARM=6 GOARCH=arm\""
fi
eval docker build . -t ${IMAGE_NAME} ${DOCKER_ARGS}

Loading…
Cancel
Save