-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(build): add support for multiarch build (#5)
* added support for multiarch image with the following supported platforms (amd64, arm64, armv7, ppc64le) * removed arm64 and ppc64le from travis builds * remove pushing image from travis. Image will be pushed from github actions * refactored build script to add new targets to make use of docker buildx * added the following workflows into github actions - release - ci - build * remove v prefix from image names * push to quay only from travis. Signed-off-by: Akhil Mohan <[email protected]>
- Loading branch information
Showing
7 changed files
with
236 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# Copyright 2018-2020 The OpenEBS Authors. All rights reserved. | ||
# | ||
# 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. | ||
name: build | ||
|
||
on: ['push'] | ||
|
||
jobs: | ||
linux-utils: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set tag | ||
run: | | ||
BRANCH="${GITHUB_REF##*/}" | ||
CI_TAG=${BRANCH#v}-ci | ||
if [ ${BRANCH} = "master" ]; then | ||
CI_TAG="ci" | ||
fi | ||
echo "::set-env name=TAG::${CI_TAG}" | ||
echo "::set-env name=BRANCH::{BRANCH}" | ||
- name: Set up Docker Buildx | ||
id: buildx | ||
uses: crazy-max/ghaction-docker-buildx@v1 | ||
with: | ||
buildx-version: latest | ||
|
||
- name: Login to GitHub Docker Registry | ||
run: echo "${DOCKERHUB_PASSWORD}" | docker login -u "${DOCKERHUB_USERNAME}" --password-stdin | ||
env: | ||
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} | ||
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }} | ||
|
||
- name: Build & Push Image | ||
run: | | ||
make buildx.image | ||
make buildx.push | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Copyright 2018-2020 The OpenEBS Authors. All rights reserved. | ||
# | ||
# 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. | ||
|
||
name: ci | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
# on pull requests to master and release branches | ||
- master | ||
- 'v*' | ||
|
||
jobs: | ||
linux-utils: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Docker Buildx | ||
id: buildx | ||
uses: crazy-max/ghaction-docker-buildx@v1 | ||
with: | ||
buildx-version: latest | ||
|
||
- name: Build Image | ||
env: | ||
IMG_RESULT: cache | ||
run: make buildx.image |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Copyright 2018-2020 The OpenEBS Authors. All rights reserved. | ||
# | ||
# 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. | ||
name: release | ||
|
||
on: | ||
create: | ||
tags: | ||
- 'v*' | ||
|
||
jobs: | ||
linux-utils: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v1 | ||
|
||
- name: Set Tag | ||
run: | | ||
echo "::set-env name=TAG::${GITHUB_REF#refs/*/v}" | ||
echo "::set-env name=RELEASE_TAG::${TAG}" | ||
- name: Set up Docker Buildx | ||
id: buildx | ||
uses: crazy-max/ghaction-docker-buildx@v1 | ||
with: | ||
version: latest | ||
|
||
- name: Login to GitHub Docker Registry | ||
env: | ||
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} | ||
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }} | ||
run: echo "${DOCKERHUB_PASSWORD}" | docker login -u "${DOCKERHUB_USERNAME}" --password-stdin | ||
|
||
- name: Build & Push Image | ||
run: | | ||
make buildx.image | ||
make buildx.push |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# Copyright 2018-2020 The OpenEBS Authors. All rights reserved. | ||
# | ||
# 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. | ||
|
||
ifeq (${TAG}, ) | ||
export TAG=ci | ||
endif | ||
|
||
# default list of platforms for which multiarch image is built | ||
ifeq (${PLATFORMS}, ) | ||
export PLATFORMS="linux/amd64,linux/arm64,linux/arm/v7,linux/ppc64le" | ||
endif | ||
|
||
# if IMG_RESULT is unspecified, by default the image will be pushed to registry | ||
ifeq (${IMG_RESULT}, load) | ||
export PUSH_ARG="--load" | ||
# if load is specified, image will be built only for the build machine architecture. | ||
export PLATFORMS="local" | ||
else ifeq (${IMG_RESULT}, cache) | ||
# if cache is specified, image will only be available in the build cache, it won't be pushed or loaded | ||
# therefore no PUSH_ARG will be specified | ||
else | ||
export PUSH_ARG="--push" | ||
endif | ||
|
||
DOCKERX_IMAGE=${IMAGE_ORG}/linux-utils:${TAG} | ||
|
||
.PHONY: buildx.image | ||
buildx.image: | ||
@if ! docker buildx ls | grep -q container-builder; then\ | ||
docker buildx create --platform ${PLATFORMS} --name container-builder --use;\ | ||
fi | ||
@docker buildx build --platform ${PLATFORMS} \ | ||
-t "$(DOCKERX_IMAGE)" ${DBUILD_ARGS} -f Dockerfile \ | ||
. ${PUSH_ARG} | ||
@echo "--> Build docker image: $(DOCKERX_IMAGE)" | ||
@echo | ||
|
||
.PHONY: buildx.push | ||
buildx.push: | ||
BUILDX=true DIMAGE=${IMAGE_ORG}/linux-utils ./buildscripts/push |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters