mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-01-03 11:45:20 +00:00
Refactor image builds to use buildx for multi arch image building (#2754)
* Refactor image builds to use buildx for multi arch image building Signed-off-by: Rob Reus <rob@devrobs.nl> * Adding image build sanity checks to Makefile Signed-off-by: Rob Reus <rob@devrobs.nl> * Making locally building of docker images possible Signed-off-by: Rob Reus <rob@devrobs.nl> * Adding docs on building container images using buildx Signed-off-by: Rob Reus <rob@devrobs.nl> * Adding changelog and implementing feedback from PR Signed-off-by: Rob Reus <rob@devrobs.nl> * Making GOPROXY used in the build containers configurable Signed-off-by: Rob Reus <rob@devrobs.nl>
This commit is contained in:
@@ -14,9 +14,11 @@
|
||||
|
||||
FROM golang:1.14
|
||||
|
||||
ARG GOPROXY
|
||||
|
||||
ENV GO111MODULE=on
|
||||
# Use a proxy for go modules to reduce the likelihood of various hosts being down and breaking the build
|
||||
ENV GOPROXY=https://proxy.golang.org
|
||||
ENV GOPROXY=${GOPROXY}
|
||||
|
||||
# get code-generation tools (for now keep in GOPATH since they're not fully modules-compatible yet)
|
||||
RUN mkdir -p /go/src/k8s.io
|
||||
@@ -54,4 +56,4 @@ RUN wget --quiet https://github.com/goreleaser/goreleaser/releases/download/v0.1
|
||||
chmod +x /usr/bin/goreleaser
|
||||
|
||||
# get golangci-lint
|
||||
RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.27.0
|
||||
RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.27.0
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
# Copyright 2016 The Kubernetes Authors.
|
||||
#
|
||||
# Modifications Copyright 2020 the Velero contributors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
@@ -18,40 +20,39 @@ set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
if [ -z "${PKG}" ]; then
|
||||
if [[ -z "${PKG}" ]]; then
|
||||
echo "PKG must be set"
|
||||
exit 1
|
||||
fi
|
||||
if [ -z "${BIN}" ]; then
|
||||
if [[ -z "${BIN}" ]]; then
|
||||
echo "BIN must be set"
|
||||
exit 1
|
||||
fi
|
||||
if [ -z "${GOOS}" ]; then
|
||||
if [[ -z "${GOOS}" ]]; then
|
||||
echo "GOOS must be set"
|
||||
exit 1
|
||||
fi
|
||||
if [ -z "${GOARCH}" ]; then
|
||||
if [[ -z "${GOARCH}" ]]; then
|
||||
echo "GOARCH must be set"
|
||||
exit 1
|
||||
fi
|
||||
if [ -z "${VERSION}" ]; then
|
||||
if [[ -z "${VERSION}" ]]; then
|
||||
echo "VERSION must be set"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "${GIT_SHA}" ]; then
|
||||
if [[ -z "${GIT_SHA}" ]]; then
|
||||
echo "GIT_SHA must be set"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
export CGO_ENABLED=0
|
||||
|
||||
if [[ -z "${GIT_DIRTY}" ]]; then
|
||||
GIT_TREE_STATE=clean
|
||||
else
|
||||
GIT_TREE_STATE=dirty
|
||||
if [[ -z "${GIT_TREE_STATE}" ]]; then
|
||||
echo "GIT_TREE_STATE must be set"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
export CGO_ENABLED=0
|
||||
|
||||
LDFLAGS="-X ${PKG}/pkg/buildinfo.Version=${VERSION}"
|
||||
LDFLAGS="${LDFLAGS} -X ${PKG}/pkg/buildinfo.GitSHA=${GIT_SHA}"
|
||||
LDFLAGS="${LDFLAGS} -X ${PKG}/pkg/buildinfo.GitTreeState=${GIT_TREE_STATE}"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright 2019 the Velero contributors.
|
||||
# Copyright 2020 the Velero contributors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -78,12 +78,21 @@ elif [[ "$TAG" == "$HIGHEST" ]]; then
|
||||
TAG_LATEST=true
|
||||
fi
|
||||
|
||||
if [[ -z "$BUILDX_PLATFORMS" ]]; then
|
||||
BUILDX_PLATFORMS="linux/amd64,linux/arm64,linux/arm/v7,linux/ppc64le"
|
||||
fi
|
||||
|
||||
# Debugging info
|
||||
echo "Highest tag found: $HIGHEST"
|
||||
echo "BRANCH: $BRANCH"
|
||||
echo "TAG: $TAG"
|
||||
echo "TAG_LATEST: $TAG_LATEST"
|
||||
echo "BUILDX_PLATFORMS: $BUILDX_PLATFORMS"
|
||||
|
||||
echo "Building and pushing container images."
|
||||
|
||||
VERSION="$VERSION" TAG_LATEST="$TAG_LATEST" make all-containers all-push all-manifests
|
||||
VERSION="$VERSION" \
|
||||
TAG_LATEST="$TAG_LATEST" \
|
||||
BUILDX_PLATFORMS="$BUILDX_PLATFORMS" \
|
||||
BUILDX_OUTPUT_TYPE="registry" \
|
||||
make all-containers
|
||||
|
||||
54
hack/download-restic.sh
Executable file
54
hack/download-restic.sh
Executable file
@@ -0,0 +1,54 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright 2020 the Velero contributors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
if [[ -z "${BIN}" ]]; then
|
||||
echo "BIN must be set"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "${BIN}" != "velero" ]]; then
|
||||
echo "${BIN} does not need the restic binary"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ -z "${GOOS}" ]]; then
|
||||
echo "GOOS must be set"
|
||||
exit 1
|
||||
fi
|
||||
if [[ -z "${GOARCH}" ]]; then
|
||||
echo "GOARCH must be set"
|
||||
exit 1
|
||||
fi
|
||||
if [[ -z "${RESTIC_VERSION}" ]]; then
|
||||
echo "RESTIC_VERSION must be set"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# TODO: when the new restic version is released, make ppc64le to be also downloaded from their github releases.
|
||||
# This has been merged and will be applied to next release: https://github.com/restic/restic/pull/2342
|
||||
if [[ "${GOARCH}" = "ppc64le" ]]; then
|
||||
wget --timeout=1 --tries=5 --quiet https://oplab9.parqtec.unicamp.br/pub/ppc64el/restic/restic-${RESTIC_VERSION} -O /output/usr/bin/restic
|
||||
else
|
||||
wget --quiet https://github.com/restic/restic/releases/download/v${RESTIC_VERSION}/restic_${RESTIC_VERSION}_${GOOS}_${GOARCH}.bz2
|
||||
bunzip2 restic_${RESTIC_VERSION}_${GOOS}_${GOARCH}.bz2
|
||||
mv restic_${RESTIC_VERSION}_${GOOS}_${GOARCH} /output/usr/bin/restic
|
||||
fi
|
||||
|
||||
chmod +x /output/usr/bin/restic
|
||||
@@ -1,34 +0,0 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright 2019 the Velero contributors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
if [ -z "${RESTIC_VERSION}" ]; then
|
||||
echo "RESTIC_VERSION must be set"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -d "_output/bin/linux/ppc64le/" ]; then
|
||||
mkdir -p _output/bin/linux/ppc64le/
|
||||
fi
|
||||
|
||||
wget --quiet https://oplab9.parqtec.unicamp.br/pub/ppc64el/restic/restic-${RESTIC_VERSION}
|
||||
mv restic-${RESTIC_VERSION} _output/bin/linux/ppc64le/restic
|
||||
chmod +x _output/bin/linux/ppc64le/restic
|
||||
|
||||
Reference in New Issue
Block a user