Browse Source

Add Golang environment and support for cross-compiling.

Add docker entrypoint script for compiling Mender client
and running mender-convert.

Changelog: Support compiling Mender client in mender-convert container.

Signed-off-by: Eystein Måløy Stenberg <eystein.maloy.stenberg@northern.tech>
1.1.x
Eystein Måløy Stenberg 6 years ago
parent
commit
f67e701486
  1. 9
      docker/Dockerfile
  2. 33
      docker/docker-entrypoint.sh

9
docker/Dockerfile

@ -2,6 +2,7 @@ FROM ubuntu:18.04
ARG MENDER_ARTIFACT_VERSION=2.3.0
ARG MENDER_CONVERT_VERSION=1.0.0
ARG GOLANG_VERSION=1.11.2
RUN apt-get update && apt-get install -y \
kpartx \
@ -46,7 +47,15 @@ RUN wget -nc -q http://releases.linaro.org/components/toolchain/binaries/6.3-201
RUN wget -q -O /usr/bin/mender-artifact https://d1b0l86ne08fsf.cloudfront.net/mender-artifact/$MENDER_ARTIFACT_VERSION/mender-artifact \
&& chmod +x /usr/bin/mender-artifact
# Golang environment, for cross-compiling the Mender client
RUN wget https://dl.google.com/go/go$GOLANG_VERSION.linux-amd64.tar.gz \
&& tar -C /usr/local -xzf go$GOLANG_VERSION.linux-amd64.tar.gz \
&& echo export PATH=$PATH:/usr/local/go/bin >> /root/.bashrc
# TODO: support selecting tag of mender-convert with MENDER_CONVERT_VERSION
# TODO: consider lighter way to download to avoid git dependency
RUN git clone https://github.com/mendersoftware/mender-convert.git
COPY docker-entrypoint.sh /usr/local/bin/
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]

33
docker/docker-entrypoint.sh

@ -0,0 +1,33 @@
#!/bin/sh
set -e
MENDER_CLIENT_VERSION="1.7.0b1" # TODO: Take as argument or env variable
echo "Cross-compiling Mender client $MENDER_CLIENT_VERSION"
# NOTE: we are assuming generic ARM board here, needs to be extended later
export PATH=$PATH:/usr/local/go/bin
export GOPATH=$HOME/go
export PATH=$PATH:/gcc-linaro-6.3.1-2017.05-x86_64_arm-linux-gnueabihf/bin
go get github.com/mendersoftware/mender
cd $GOPATH/src/github.com/mendersoftware/mender
git checkout $MENDER_CLIENT_VERSION
env CGO_ENABLED=1 \
CC=arm-linux-gnueabihf-gcc \
GOOS=linux \
GOARCH=arm make build
cp $GOPATH/src/github.com/mendersoftware/mender/mender /
# run conversion, args provided to container (end of docker run ...)
cd /mender-convert
echo "Running mender-convert "$@""
./mender-convert "$@"
Loading…
Cancel
Save