Skip to content

Commit

Permalink
with DOCKER_PUSH to true
Browse files Browse the repository at this point in the history
Signed-off-by: mickkael <[email protected]>
  • Loading branch information
mickkael committed May 27, 2021
1 parent a7ca361 commit 5a2d79b
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 26 deletions.
57 changes: 34 additions & 23 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Set up QEMU
uses: docker/setup-qemu-action@v1
with:
platforms: amd64,arm64
# - name: Set up QEMU
# uses: docker/setup-qemu-action@v1
# with:
# platforms: amd64,arm64

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
Expand All @@ -66,31 +66,42 @@ jobs:
registry: quay.io
username: ${{ secrets.QUAYIO_USERNAME }}
password: ${{ secrets.QUAYIO_PASSWORD }}

- name: set tag csv value
id: tag
env:
QUAYIO_ORG: ${{ secrets.QUAYIO_ORG }}
TARGET: ${{ matrix.target }}

- name: set Version
id: version
run: |
tag=$(basename $GITHUB_REF)
if [ $tag = "master" ]; then
tag="latest"
fi
image_name="${QUAYIO_ORG}/${TARGET}:${tag}"
echo "::set-output name=TAG_LIST::$image_name"
echo "::set-output name=VERSION::$tag"
- name: Container build and push
uses: docker/build-push-action@v2
env:
QUAYIO_ORG: ${{ secrets.QUAYIO_ORG }}
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: "true"
tags: ${{ steps.tag.outputs.TAG_LIST }}
target: ${{ matrix.target }}
- name: Container build and push with arm64/amd64
run: |
VERSION=${{ steps.version.outputs.VERSION }} DO_BUILD=false DOCKER_PUSH=true make image-multi
# - name: set tag csv value
# id: tag
# env:
# QUAYIO_ORG: ${{ secrets.QUAYIO_ORG }}
# TARGET: ${{ matrix.target }}
# run: |
# tag=$(basename $GITHUB_REF)
# if [ $tag = "master" ]; then
# tag="latest"
# fi
# image_name="quay.io/${QUAYIO_ORG}/${TARGET}:${tag}"
# echo "::set-output name=TAG_LIST::$image_name"
#
# - name: Container build and push
# uses: docker/build-push-action@v2
# with:
# context: .
# file: ./Dockerfile
# platforms: linux/amd64,linux/arm64
# push: "true"
# tags: ${{ steps.tag.outputs.TAG_LIST }}
# target: ${{ matrix.target }}

release:
runs-on: ubuntu-latest
Expand Down
11 changes: 8 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ DOCKER_PUSH?=false
IMAGE_NAMESPACE?=quay.io/argoproj
VERSION?=latest
BASE_VERSION:=latest
DO_BUILD?=true

override LDFLAGS += \
-X ${PACKAGE}.version=${VERSION} \
Expand All @@ -25,6 +26,7 @@ override LDFLAGS += \
-X ${PACKAGE}.gitTreeState=${GIT_TREE_STATE}

ifeq (${DOCKER_PUSH},true)
PUSH_OPTION="--push"
ifndef IMAGE_NAMESPACE
$(error IMAGE_NAMESPACE must be set to push images (e.g. IMAGE_NAMESPACE=quay.io/argoproj))
endif
Expand Down Expand Up @@ -66,9 +68,12 @@ image-linux-%: dist/$(BINARY_NAME)-linux-$*
DOCKER_BUILDKIT=1 docker build --build-arg "ARCH=$*" -t $(IMAGE_NAMESPACE)/$(BINARY_NAME):$(VERSION)-linux-$* --platform "linux/$*" --target $(BINARY_NAME) -f $(DOCKERFILE) .
@if [ "$(DOCKER_PUSH)" = "true" ]; then docker push $(IMAGE_NAMESPACE)/$(BINARY_NAME):$(VERSION)-linux-$*; fi

image-multi: image-linux-amd64 image-linux-arm64
DOCKER_CLI_EXPERIMENTAL=enabled docker manifest create $(IMAGE_NAMESPACE)/$(BINARY_NAME):$(VERSION) $(IMAGE_NAMESPACE)/$(BINARY_NAME):$(VERSION)-linux-arm64 $(IMAGE_NAMESPACE)/$(BINARY_NAME):$(VERSION)-linux-amd64
@if [ "$(DOCKER_PUSH)" = "true" ]; then docker manifest push $(IMAGE_NAMESPACE)/$(BINARY_NAME):$(VERSION); fi
image-multi: set-qemu $(if $(DO_BUILD), dist/$(BINARY_NAME)-linux-arm64 dist/$(BINARY_NAME)-linux-amd64)
docker buildx build --tag $(IMAGE_NAMESPACE)/$(BINARY_NAME):$(VERSION) --target $(BINARY_NAME) --platform linux/amd64,linux/arm64 --file ./Dockerfile ${PUSH_OPTION} .

set-qemu:
docker pull tonistiigi/binfmt:latest
docker run --rm --privileged tonistiigi/binfmt:latest --install amd64,arm64

test:
go test $(shell go list ./... | grep -v /vendor/ | grep -v /test/e2e/) -race -short -v
Expand Down

0 comments on commit 5a2d79b

Please sign in to comment.