Add compile restic binary for CVE fix

Signed-off-by: Ming <mqiu@vmware.com>
pull/5574/head
Ming 2022-11-09 07:23:18 +00:00
parent cd371419e3
commit fc0c470395
3 changed files with 8 additions and 7 deletions

View File

@ -29,8 +29,6 @@ WORKDIR /go/src/github.com/vmware-tanzu/velero
COPY . /go/src/github.com/vmware-tanzu/velero COPY . /go/src/github.com/vmware-tanzu/velero
RUN apt-get update && apt-get install -y bzip2
FROM --platform=$BUILDPLATFORM builder-env as builder FROM --platform=$BUILDPLATFORM builder-env as builder
ARG TARGETOS ARG TARGETOS
@ -45,7 +43,7 @@ ENV GOOS=${TARGETOS} \
GOARM=${TARGETVARIANT} GOARM=${TARGETVARIANT}
RUN mkdir -p /output/usr/bin && \ RUN mkdir -p /output/usr/bin && \
bash ./hack/download-restic.sh && \ bash ./hack/build-restic.sh && \
export GOARM=$( echo "${GOARM}" | cut -c2-) && \ export GOARM=$( echo "${GOARM}" | cut -c2-) && \
go build -o /output/${BIN} \ go build -o /output/${BIN} \
-ldflags "${LDFLAGS}" ${PKG}/cmd/${BIN} -ldflags "${LDFLAGS}" ${PKG}/cmd/${BIN}

View File

@ -0,0 +1 @@
Add compile restic binary for CVE fix

View File

@ -22,6 +22,7 @@ set -o pipefail
# is the path expected by the Velero Dockerfile. # is the path expected by the Velero Dockerfile.
output_dir=${OUTPUT_DIR:-/output/usr/bin} output_dir=${OUTPUT_DIR:-/output/usr/bin}
restic_bin=${output_dir}/restic restic_bin=${output_dir}/restic
build_path=$(dirname "$PWD")
if [[ -z "${BIN}" ]]; then if [[ -z "${BIN}" ]]; then
echo "BIN must be set" echo "BIN must be set"
@ -46,8 +47,9 @@ if [[ -z "${RESTIC_VERSION}" ]]; then
exit 1 exit 1
fi fi
curl -s -L https://github.com/restic/restic/releases/download/v${RESTIC_VERSION}/restic_${RESTIC_VERSION}_${GOOS}_${GOARCH}.bz2 -O mkdir ${build_path}/restic
bunzip2 restic_${RESTIC_VERSION}_${GOOS}_${GOARCH}.bz2 git clone -b v${RESTIC_VERSION} https://github.com/restic/restic.git ${build_path}/restic
mv restic_${RESTIC_VERSION}_${GOOS}_${GOARCH} ${restic_bin} pushd ${build_path}/restic
go run build.go -o ${restic_bin}
chmod +x ${restic_bin} chmod +x ${restic_bin}
popd