-
Notifications
You must be signed in to change notification settings - Fork 140
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
Added Arm Multi-arch Make Logic #36
Changes from 1 commit
20a699d
51ee020
11913e8
e79a53a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Copyright 2017, 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. | ||
|
||
FROM golang:1.13-buster AS build | ||
WORKDIR /go/src/github.com/vmware-tanzu/velero-plugin-for-aws | ||
# copy vendor in separately so the layer can be cached if the contents don't change | ||
COPY vendor vendor | ||
COPY velero-plugin-for-aws velero-plugin-for-aws | ||
RUN GOARCH=arm CGO_ENABLED=0 GOOS=linux go build -v -o /go/bin/velero-plugin-for-aws ./velero-plugin-for-aws | ||
|
||
|
||
FROM arm32v7/ubuntu:bionic | ||
#RUN mkdir /plugins | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove commented steps in the Dockerfiles. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Comment removed from both dockerfiles. |
||
COPY --from=build /go/bin/velero-plugin-for-aws /plugins/ | ||
USER nobody:nogroup | ||
ENTRYPOINT ["/bin/bash", "-c", "cp /plugins/* /target/."] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Copyright 2017, 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. | ||
|
||
FROM golang:1.13-buster AS build | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we please switch this to golang 1.14? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This needs to be done on the other dockerfile too. |
||
WORKDIR /go/src/github.com/vmware-tanzu/velero-plugin-for-aws | ||
# copy vendor in separately so the layer can be cached if the contents don't change | ||
COPY vendor vendor | ||
COPY velero-plugin-for-aws velero-plugin-for-aws | ||
RUN GOARCH=arm64 CGO_ENABLED=0 GOOS=linux go build -v -o /go/bin/velero-plugin-for-aws ./velero-plugin-for-aws | ||
|
||
|
||
FROM arm64v8/ubuntu:bionic | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we use the more recent There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This needs to be done on the other dockerfile too. |
||
#RUN mkdir /plugins | ||
COPY --from=build /go/bin/velero-plugin-for-aws /plugins/ | ||
USER nobody:nogroup | ||
ENTRYPOINT ["/bin/bash", "-c", "cp /plugins/* /target/."] |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,9 +16,10 @@ PKG := github.com/vmware-tanzu/velero-plugin-for-aws | |
BIN := velero-plugin-for-aws | ||
|
||
REGISTRY ?= velero | ||
IMAGE ?= $(REGISTRY)/velero-plugin-for-aws | ||
VERSION ?= master | ||
|
||
CONTAINER_PLATFORMS ?= amd64 arm arm64 # ppc64le | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think ppc64le needs to be removed entirely; it's not supported by Velero itself. |
||
|
||
# Which architecture to build. | ||
# if the 'local' rule is being run, detect the GOOS/GOARCH from 'go env' | ||
# if it wasn't specified by the caller. | ||
|
@@ -28,6 +29,37 @@ GOOS ?= linux | |
local: GOARCH ?= $(shell go env GOARCH) | ||
GOARCH ?= amd64 | ||
|
||
# Set default base image dynamically for each arch | ||
ifeq ($(GOARCH),amd64) | ||
DOCKERFILE ?= Dockerfile | ||
endif | ||
ifeq ($(GOARCH),arm) | ||
DOCKERFILE ?= Dockerfile-arm | ||
endif | ||
ifeq ($(GOARCH),arm64) | ||
DOCKERFILE ?= Dockerfile-arm64 | ||
endif | ||
|
||
|
||
MULTIARCH_IMAGE = $(REGISTRY)/$(BIN) | ||
IMAGE ?= $(REGISTRY)/$(BIN)-$(GOARCH) | ||
|
||
# If you want to build all containers, see the 'all-containers' rule. | ||
# If you want to build AND push all containers, see the 'all-push' rule. | ||
|
||
container-%: | ||
@$(MAKE) --no-print-directory GOARCH=$* container | ||
|
||
push-%: | ||
@$(MAKE) --no-print-directory GOARCH=$* push | ||
|
||
all-containers: $(addprefix container-, $(CONTAINER_PLATFORMS)) | ||
|
||
all-push: $(addprefix push-, $(CONTAINER_PLATFORMS)) | ||
|
||
all-manifests: | ||
@$(MAKE) manifest | ||
|
||
# local builds the binary using 'go build' in the local environment. | ||
local: build-dirs | ||
GOOS=$(GOOS) \ | ||
|
@@ -44,18 +76,37 @@ test: | |
# ci is a convenience target for CI builds. | ||
ci: test | ||
|
||
|
||
# container builds a Docker image containing the binary. | ||
container: | ||
docker build -t $(IMAGE):$(VERSION) . | ||
docker build -t $(IMAGE):$(VERSION) -f $(DOCKERFILE) . | ||
@echo "container: $(IMAGE):$(VERSION)" | ||
|
||
|
||
# push pushes the Docker image to its registry. | ||
push: | ||
@docker push $(IMAGE):$(VERSION) | ||
@echo "pushed: $(IMAGE):$(VERSION)" | ||
ifeq ($(TAG_LATEST), true) | ||
docker tag $(IMAGE):$(VERSION) $(IMAGE):latest | ||
docker push $(IMAGE):latest | ||
@echo "pushed: $(IMAGE):latest" | ||
endif | ||
|
||
|
||
manifest: | ||
DOCKER_CLI_EXPERIMENTAL=enabled docker manifest create $(MULTIARCH_IMAGE):$(VERSION) \ | ||
$(foreach arch, $(CONTAINER_PLATFORMS), $(MULTIARCH_IMAGE)-$(arch):$(VERSION)) | ||
@DOCKER_CLI_EXPERIMENTAL=enabled docker manifest push --purge $(MULTIARCH_IMAGE):$(VERSION) | ||
@echo "pushed: $(MULTIARCH_IMAGE):$(VERSION)" | ||
ifeq ($(TAG_LATEST), true) | ||
@DOCKER_CLI_EXPERIMENTAL=enabled docker manifest create $(MULTIARCH_IMAGE):latest \ | ||
$(foreach arch, $(CONTAINER_PLATFORMS), $(MULTIARCH_IMAGE)-$(arch):latest) | ||
@DOCKER_CLI_EXPERIMENTAL=enabled docker manifest push --purge $(MULTIARCH_IMAGE):latest | ||
@echo "pushed: $(MULTIARCH_IMAGE):latest)" | ||
endif | ||
|
||
|
||
# build-dirs creates the necessary directories for a build in the local environment. | ||
build-dirs: | ||
@mkdir -p _output | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copyright boilerplate should have 2020 as the year.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Year has been updated.