Clean up architecture handling

* Remove unused release.sh and DAPPER_HOST_ARCH
* Reliably use ARCH from version.sh
* Export GOARCH and GOARM so that they are used by `go build`

Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
pull/2558/head
Brad Davidson 4 years ago committed by Brad Davidson
parent cb5b9edf32
commit 10474638d7

@ -28,10 +28,7 @@ RUN mkdir -p /go/src/golang.org/x && \
go install golang.org/x/tools/cmd/goimports && cd
RUN rm -rf /go/src /go/pkg
ARG DAPPER_HOST_ARCH
ENV ARCH $DAPPER_HOST_ARCH
RUN if [ "${ARCH}" = 'amd64' ]; then \
RUN if [ "$(go env GOARCH)" = "amd64" ]; then \
curl -sL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s v1.30.0; \
fi

@ -2,19 +2,16 @@ FROM golang:1.15.2-alpine3.12
RUN apk -U --no-cache add bash git gcc musl-dev docker curl jq coreutils python2 openssl
ARG DAPPER_HOST_ARCH
ENV ARCH $DAPPER_HOST_ARCH
ENV SONOBUOY_VERSION 0.19.0
RUN if [ "${ARCH}" == "amd64" ] || [ "${ARCH}" == "arm64" ]; then \
OS=linux && \
curl -sL "https://github.com/vmware-tanzu/sonobuoy/releases/download/v${SONOBUOY_VERSION}/sonobuoy_${SONOBUOY_VERSION}_${OS}_${ARCH}.tar.gz" | \
tar -xzf - -C /usr/local/bin; \
fi
RUN curl -sL https://storage.googleapis.com/kubernetes-release/release/$( \
curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt \
)/bin/linux/${ARCH}/kubectl -o /usr/local/bin/kubectl && \
RUN OS=linux; \
ARCH=$(go env GOARCH); \
RELEASE=$(curl -fs https://storage.googleapis.com/kubernetes-release/release/stable.txt); \
if [ "${ARCH}" == "amd64" ] || [ "${ARCH}" == "arm64" ]; then \
curl -sL "https://github.com/vmware-tanzu/sonobuoy/releases/download/v${SONOBUOY_VERSION}/sonobuoy_${SONOBUOY_VERSION}_${OS}_${ARCH}.tar.gz" | \
tar -xzf - -C /usr/local/bin; \
fi; \
curl -fsL https://storage.googleapis.com/kubernetes-release/release/${RELEASE}/bin/linux/${ARCH}/kubectl -o /usr/local/bin/kubectl; \
chmod a+x /usr/local/bin/kubectl
ENV TEST_CLEANUP true

@ -6,6 +6,8 @@ if [ "${DEBUG}" = 1 ]; then
set -x
fi
. ./scripts/version.sh
MAX_BINARY_SIZE=61000000
BIN_SUFFIX="-${ARCH}"
if [ ${ARCH} = amd64 ]; then
@ -18,8 +20,9 @@ CMD_NAME="dist/artifacts/k3s${BIN_SUFFIX}"
SIZE=$(stat -c '%s' ${CMD_NAME})
if [ ${SIZE} -gt ${MAX_BINARY_SIZE} ]; then
echo "k3s binary ${CMD_NAME} size ${SIZE} exceeds acceptable size of ${MAX_BINARY_SIZE}"
echo "k3s binary ${CMD_NAME} size ${SIZE} exceeds max acceptable size of ${MAX_BINARY_SIZE} bytes"
exit 1
fi
echo "k3s binary ${CMD_NAME} size ${SIZE} is less than max acceptable size of ${MAX_BINARY_SIZE} bytes"
exit 0

@ -63,8 +63,9 @@ fi
mkdir -p bin
if [ -z "$GOARM" ] && [ "arm" = "$("${GO}" env GOARCH)" ]; then
GOARM=7
if [ ${ARCH} = armv7l ] || [ ${ARCH} = arm ]; then
export GOARCH="arm"
export GOARM="7"
fi
rm -f \

@ -1,39 +0,0 @@
#!/bin/bash
set -e
cd $(dirname $0)/..
if [ -z "$K3S_ARM64_HOST" ]; then
echo K3S_ARM_HOST must be set
exit 1
fi
if [ -z "$K3S_ARM64_HOST_USER" ]; then
echo K3S_ARM_HOST_USER must be set
exit 1
fi
if [ -z "$K3S_ARM_HOST" ]; then
K3S_ARM_HOST=${K3S_ARM64_HOST}
fi
if [ -z "$K3S_ARM_HOST_USER" ]; then
K3S_ARM_HOST_USER=${K3S_ARM64_HOST_USER}
fi
rm -rf dist
mkdir -p build
make ci > build/build-amd64.log 2>&1 &
AMD_PID=$!
DAPPER_HOST_ARCH=arm DOCKER_HOST="ssh://${K3S_ARM_HOST_USER}@${K3S_ARM_HOST}" make release-arm
DAPPER_HOST_ARCH=arm64 DOCKER_HOST="ssh://${K3S_ARM64_HOST_USER}@${K3S_ARM64_HOST}" make release-arm
echo Waiting for amd64 build to finish
wait -n $AMD_PID || {
cat build/build-amd64.log
exit 1
}
ls -la dist
echo Done

@ -2,6 +2,7 @@
set -e -x
cd $(dirname $0)/..
. ./scripts/version.sh
. ./scripts/test-helpers
artifacts=$(pwd)/dist/artifacts

Loading…
Cancel
Save