diff --git a/Tiltfile b/Tiltfile index 0bc5e0019..a47ab9551 100644 --- a/Tiltfile +++ b/Tiltfile @@ -72,15 +72,6 @@ COPY --from=tilt-helper /usr/bin/docker /usr/bin/docker COPY --from=tilt-helper /go/kubernetes/client/bin/kubectl /usr/bin/kubectl """ -docker_build_download_restic_commands = """ -COPY ./hack/download-restic.sh / -RUN apt update && apt install -y wget -RUN mkdir -p /output/usr/bin && \ - BIN=velero GOOS=linux GOARCH=amd64 RESTIC_VERSION=0.9.6 /download-restic.sh && \ - mv /output/usr/bin/restic /usr/bin/restic && \ - rm -rf /output/usr/bin -""" - ############################## # Setup Velero ############################## @@ -110,13 +101,19 @@ local_resource( deps = ["internal", "pkg/cmd"], ) +local_resource( + "restic_binary", + cmd = 'cd ' + '.' + ';mkdir -p _tiltbuild/restic; BIN=velero GOOS=' + local_goos + ' GOARCH=amd64 RESTIC_VERSION=0.9.6 OUTPUT_DIR=_tiltbuild/restic ./hack/download-restic.sh', +) + # Note: we need a distro with a bash shell to exec into the Velero container tilt_dockerfile_header = """ FROM ubuntu:focal as tilt WORKDIR / COPY --from=tilt-helper /start.sh . COPY --from=tilt-helper /restart.sh . -COPY _tiltbuild/velero . +COPY velero . +COPY restic/restic /usr/bin/restic """ dockerfile_contents = "\n".join([ @@ -124,10 +121,8 @@ dockerfile_contents = "\n".join([ additional_docker_helper_commands, tilt_dockerfile_header, additional_docker_build_commands, - docker_build_download_restic_commands, ]) - def get_velero_entrypoint(): """ Returns the entrypoint for the Velero container image. @@ -156,7 +151,7 @@ def get_velero_entrypoint(): # build into the container. docker_build( ref = "velero/velero", - context = ".", + context = "_tiltbuild", dockerfile_contents = dockerfile_contents, target = "tilt", entrypoint = get_velero_entrypoint(), diff --git a/hack/download-restic.sh b/hack/download-restic.sh index 230c9cf65..93554f0c0 100755 --- a/hack/download-restic.sh +++ b/hack/download-restic.sh @@ -18,6 +18,11 @@ set -o errexit set -o nounset set -o pipefail +# Use /output/usr/bin/ as the default output directory as this +# is the path expected by the Velero Dockerfile. +output_dir=${OUTPUT_DIR:-/output/usr/bin} +restic_bin=${output_dir}/restic + if [[ -z "${BIN}" ]]; then echo "BIN must be set" exit 1 @@ -44,11 +49,11 @@ 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 + wget --timeout=1 --tries=5 --quiet https://oplab9.parqtec.unicamp.br/pub/ppc64el/restic/restic-${RESTIC_VERSION} -O ${restic_bin} 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 + mv restic_${RESTIC_VERSION}_${GOOS}_${GOARCH} ${restic_bin} fi -chmod +x /output/usr/bin/restic +chmod +x ${restic_bin}