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 go install golang.org/x/tools/cmd/goimports && cd
RUN rm -rf /go/src /go/pkg RUN rm -rf /go/src /go/pkg
ARG DAPPER_HOST_ARCH RUN if [ "$(go env GOARCH)" = "amd64" ]; then \
ENV ARCH $DAPPER_HOST_ARCH
RUN if [ "${ARCH}" = 'amd64' ]; then \
curl -sL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s v1.30.0; \ curl -sL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s v1.30.0; \
fi 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 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 ENV SONOBUOY_VERSION 0.19.0
RUN if [ "${ARCH}" == "amd64" ] || [ "${ARCH}" == "arm64" ]; then \ RUN OS=linux; \
OS=linux && \ ARCH=$(go env GOARCH); \
curl -sL "https://github.com/vmware-tanzu/sonobuoy/releases/download/v${SONOBUOY_VERSION}/sonobuoy_${SONOBUOY_VERSION}_${OS}_${ARCH}.tar.gz" | \ RELEASE=$(curl -fs https://storage.googleapis.com/kubernetes-release/release/stable.txt); \
tar -xzf - -C /usr/local/bin; \ if [ "${ARCH}" == "amd64" ] || [ "${ARCH}" == "arm64" ]; then \
fi 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; \
RUN curl -sL https://storage.googleapis.com/kubernetes-release/release/$( \ fi; \
curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt \ curl -fsL https://storage.googleapis.com/kubernetes-release/release/${RELEASE}/bin/linux/${ARCH}/kubectl -o /usr/local/bin/kubectl; \
)/bin/linux/${ARCH}/kubectl -o /usr/local/bin/kubectl && \
chmod a+x /usr/local/bin/kubectl chmod a+x /usr/local/bin/kubectl
ENV TEST_CLEANUP true ENV TEST_CLEANUP true

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

@ -63,8 +63,9 @@ fi
mkdir -p bin mkdir -p bin
if [ -z "$GOARM" ] && [ "arm" = "$("${GO}" env GOARCH)" ]; then if [ ${ARCH} = armv7l ] || [ ${ARCH} = arm ]; then
GOARM=7 export GOARCH="arm"
export GOARM="7"
fi fi
rm -f \ 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 set -e -x
cd $(dirname $0)/.. cd $(dirname $0)/..
. ./scripts/version.sh
. ./scripts/test-helpers . ./scripts/test-helpers
artifacts=$(pwd)/dist/artifacts artifacts=$(pwd)/dist/artifacts

Loading…
Cancel
Save