Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiarch image support #1768

Merged
merged 17 commits into from
Jan 7, 2020
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Dockerfile-fsfreeze-pause-ppc64le
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM ubuntu:bionic
FROM ppc64le/ubuntu:bionic

LABEL maintainer="Steve Kriss <krisss@vmware.com>"
LABEL maintainer="Prajyot Parab <prajyot.parab@ibm.com>"

ENTRYPOINT ["/bin/bash", "-c", "while true; do sleep 10000; done"]
13 changes: 3 additions & 10 deletions Dockerfile-velero-ppc64le
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM ubuntu:bionic
FROM ppc64le/ubuntu:bionic

LABEL maintainer="Steve Kriss <[email protected]>"

RUN apt-get update && \
apt-get install -y --no-install-recommends ca-certificates wget && \
wget --quiet https://oplab9.parqtec.unicamp.br/pub/ppc64el/restic/restic-0.9.4 && \
mv restic-0.9.4 /usr/bin/restic && \
chmod +x /usr/bin/restic && \
apt-get remove -y wget && \
rm -rf /var/lib/apt/lists/*
LABEL maintainer="Prajyot Parab <[email protected]>"

ADD /bin/linux/ppc64le/restic /usr/bin/restic

ADD /bin/linux/ppc64le/velero /velero

Expand Down
4 changes: 2 additions & 2 deletions Dockerfile-velero-restic-restore-helper-ppc64le
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM ubuntu:bionic
FROM ppc64le/ubuntu:bionic

LABEL maintainer="Steve Kriss <krisss@vmware.com>"
LABEL maintainer="Prajyot Parab <prajyot.parab@ibm.com>"

ADD /bin/linux/ppc64le/velero-restic-restore-helper .

Expand Down
72 changes: 53 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,16 @@ VERSION ?= master

TAG_LATEST ?= false

# The version of restic binary to be downloaded for power architecture
RESTIC_VERSION ?= 0.9.4
skriss marked this conversation as resolved.
Show resolved Hide resolved

###
### These variables should not need tweaking.
###

CLI_PLATFORMS := linux-amd64 linux-arm linux-arm64 darwin-amd64 windows-amd64 linux-ppc64le
skriss marked this conversation as resolved.
Show resolved Hide resolved
CONTAINER_PLATFORMS := linux-amd64 linux-arm linux-arm64 linux-ppc64le
CONTAINER_PLATFORMS := linux-amd64 linux-ppc64le #linux-arm linux-arm64
nrb marked this conversation as resolved.
Show resolved Hide resolved
MANIFEST_PLATFORMS := amd64 ppc64le

platform_temp = $(subst -, ,$(ARCH))
GOOS = $(word 1, $(platform_temp))
Expand All @@ -48,6 +52,8 @@ GOARCH = $(word 2, $(platform_temp))
# Set default base image dynamically for each arch
skriss marked this conversation as resolved.
Show resolved Hide resolved
ifeq ($(GOARCH),amd64)
DOCKERFILE ?= Dockerfile-$(BIN)
local-arch:
skriss marked this conversation as resolved.
Show resolved Hide resolved
@echo "local environment for amd64 is up-to-date"
endif
#ifeq ($(GOARCH),arm)
# DOCKERFILE ?= Dockerfile.arm #armel/busybox
Expand All @@ -57,9 +63,13 @@ endif
#endif
ifeq ($(GOARCH),ppc64le)
DOCKERFILE ?= Dockerfile-$(BIN)-ppc64le
local-arch:
RESTIC_VERSION=$(RESTIC_VERSION) \
./hack/get-restic-ppc64le.sh
skriss marked this conversation as resolved.
Show resolved Hide resolved
endif

IMAGE = $(REGISTRY)/$(BIN)
MULTIARCH_IMAGE = $(REGISTRY)/$(BIN)
IMAGE = $(REGISTRY)/$(BIN)-$(GOARCH)

# If you want to build all binaries, see the 'all-build' rule.
# If you want to build all containers, see the 'all-container' rule.
Expand All @@ -70,18 +80,28 @@ all:

build-%:
@$(MAKE) --no-print-directory ARCH=$* build
@$(MAKE) --no-print-directory ARCH=$* build BIN=velero-restic-restore-helper

#container-%:
# @$(MAKE) --no-print-directory ARCH=$* container
container-%:
@$(MAKE) --no-print-directory ARCH=$* container
@$(MAKE) --no-print-directory ARCH=$* container BIN=velero-restic-restore-helper
@$(MAKE) --no-print-directory ARCH=$* build-fsfreeze

#push-%:
# @$(MAKE) --no-print-directory ARCH=$* push
push-%:
@$(MAKE) --no-print-directory ARCH=$* push
@$(MAKE) --no-print-directory ARCH=$* push BIN=velero-restic-restore-helper
@$(MAKE) --no-print-directory ARCH=$* push-fsfreeze

all-build: $(addprefix build-, $(CLI_PLATFORMS))

#all-container: $(addprefix container-, $(CONTAINER_PLATFORMS))
all-container: $(addprefix container-, $(CONTAINER_PLATFORMS))
nrb marked this conversation as resolved.
Show resolved Hide resolved

all-push: $(addprefix push-, $(CONTAINER_PLATFORMS))

#all-push: $(addprefix push-, $(CONTAINER_PLATFORMS))
all-manifest:
nrb marked this conversation as resolved.
Show resolved Hide resolved
@$(MAKE) manifest
@$(MAKE) manifest BIN=velero-restic-restore-helper
@$(MAKE) manifest-fsfreeze

local: build-dirs
GOOS=$(GOOS) \
Expand Down Expand Up @@ -147,12 +167,18 @@ ifeq ($(TAG_LATEST), true)
endif
@docker images -q $(REGISTRY)/fsfreeze-pause:$(VERSION) > .container-$(DOTFILE_IMAGE)

all-containers:
$(MAKE) container
$(MAKE) container BIN=velero-restic-restore-helper
$(MAKE) build-fsfreeze
manifest-fsfreeze: BIN = fsfreeze-pause
manifest-fsfreeze:
@docker manifest create $(MULTIARCH_IMAGE):$(VERSION) \
$(foreach arch, $(MANIFEST_PLATFORMS), $(MULTIARCH_IMAGE)-$(arch):$(VERSION))
@docker manifest push $(MULTIARCH_IMAGE):$(VERSION)
ifeq ($(TAG_LATEST), true)
docker manifest create $(MULTIARCH_IMAGE):latest \
$(foreach arch, $(MANIFEST_PLATFORMS), $(MULTIARCH_IMAGE)-$(arch):latest)
docker manifest push $(MULTIARCH_IMAGE):latest
endif

container: verify test .container-$(DOTFILE_IMAGE) container-name
container: verify test local-arch .container-$(DOTFILE_IMAGE) container-name
.container-$(DOTFILE_IMAGE): _output/bin/$(GOOS)/$(GOARCH)/$(BIN) $(DOCKERFILE)
@cp $(DOCKERFILE) _output/.dockerfile-$(BIN)-$(GOOS)-$(GOARCH)
@docker build --pull -t $(IMAGE):$(VERSION) -f _output/.dockerfile-$(BIN)-$(GOOS)-$(GOARCH) _output
Expand All @@ -161,12 +187,6 @@ container: verify test .container-$(DOTFILE_IMAGE) container-name
container-name:
@echo "container: $(IMAGE):$(VERSION)"

all-push:
$(MAKE) push
$(MAKE) push BIN=velero-restic-restore-helper
$(MAKE) push-fsfreeze


push: .push-$(DOTFILE_IMAGE) push-name
.push-$(DOTFILE_IMAGE): .container-$(DOTFILE_IMAGE)
@docker push $(IMAGE):$(VERSION)
Expand All @@ -179,6 +199,20 @@ endif
push-name:
@echo "pushed: $(IMAGE):$(VERSION)"

manifest: .manifest-$(MULTIARCH_IMAGE) manifest-name
.manifest-$(MULTIARCH_IMAGE):
@docker manifest create $(MULTIARCH_IMAGE):$(VERSION) \
skriss marked this conversation as resolved.
Show resolved Hide resolved
skriss marked this conversation as resolved.
Show resolved Hide resolved
$(foreach arch, $(MANIFEST_PLATFORMS), $(MULTIARCH_IMAGE)-$(arch):$(VERSION))
@docker manifest push $(MULTIARCH_IMAGE):$(VERSION)
ifeq ($(TAG_LATEST), true)
docker manifest create $(MULTIARCH_IMAGE):latest \
$(foreach arch, $(MANIFEST_PLATFORMS), $(MULTIARCH_IMAGE)-$(arch):latest)
docker manifest push $(MULTIARCH_IMAGE):latest
endif

manifest-name:
@echo "pushed: $(MULTIARCH_IMAGE):$(VERSION)"

SKIP_TESTS ?=
test: build-dirs
ifneq ($(SKIP_TESTS), 1)
Expand Down
1 change: 1 addition & 0 deletions changelogs/unreleased/1768-prajyot-parab
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added support for multi-arch images
nrb marked this conversation as resolved.
Show resolved Hide resolved
30 changes: 30 additions & 0 deletions hack/get-restic-ppc64le.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/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

wget --quiet https://oplab9.parqtec.unicamp.br/pub/ppc64el/restic/restic-${RESTIC_VERSION}
nrb marked this conversation as resolved.
Show resolved Hide resolved
mv restic-${RESTIC_VERSION} _output/bin/linux/ppc64le/restic
chmod +x _output/bin/linux/ppc64le/restic