-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
swiched to buildkit for multi-arch builds
- Loading branch information
1 parent
6798df4
commit d6cda4c
Showing
4 changed files
with
27 additions
and
22 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
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 |
---|---|---|
|
@@ -4,7 +4,7 @@ MAINTAINER Michal Orzechowski <[email protected]> | |
|
||
ARG VCS_REF | ||
ARG BUILD_DATE | ||
ARG TARGET_PLATFORM | ||
ARG TARGETARCH | ||
|
||
# Metadata | ||
LABEL org.label-schema.vcs-ref=$VCS_REF \ | ||
|
@@ -15,7 +15,7 @@ LABEL org.label-schema.vcs-ref=$VCS_REF \ | |
ENV KUBE_LATEST_VERSION="v1.24.0" | ||
|
||
RUN apk add --update --no-cache ca-certificates=20211220-r0 curl=7.80.0-r1 jq=1.6-r1 \ | ||
&& curl -L https://storage.googleapis.com/kubernetes-release/release/${KUBE_LATEST_VERSION}/bin/linux/$TARGET_PLATFORM/kubectl -o /usr/local/bin/kubectl \ | ||
&& curl -L https://storage.googleapis.com/kubernetes-release/release/${KUBE_LATEST_VERSION}/bin/linux/$TARGETARCH/kubectl -o /usr/local/bin/kubectl \ | ||
&& chmod +x /usr/local/bin/kubectl | ||
|
||
ADD wait_for.sh /usr/local/bin/wait_for.sh | ||
|
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 |
---|---|---|
@@ -1,27 +1,33 @@ | ||
TAG = $(shell git describe --tags --always) | ||
PREFIX = $(shell git config --get remote.origin.url | tr ':.' '/' | rev | cut -d '/' -f 3 | rev) | ||
REPO_NAME = $(shell git config --get remote.origin.url | tr ':.' '/' | rev | cut -d '/' -f 2 | rev) | ||
TARGET = $(shell ./evaluate_platform.sh) | ||
TARGET := $(if $(TARGET),$(TARGET),$(shell ./evaluate_platform.sh)) | ||
VCS_REF = $(shell git rev-parse --short HEAD) | ||
BUILD_DATE = $(shell date -u +'%Y-%m-%dT%H:%M:%SZ') | ||
BUILD_FLAGS := $(if $(BUILD_FLAGS),$(BUILD_FLAGS),--load --no-cache) | ||
BUILDER_NAME = k8s-wait-for-builder | ||
DOCKER_TAGS= $(PREFIX)/$(REPO_NAME):latest $(PREFIX)/$(REPO_NAME):$(TAG) ghcr.io/$(PREFIX)/$(REPO_NAME):latest ghcr.io/$(PREFIX)/$(REPO_NAME):$(TAG) | ||
|
||
all: push | ||
|
||
container: image | ||
|
||
image: | ||
@echo TARGET IS $(TARGET) | ||
docker build --no-cache -t $(PREFIX)/$(REPO_NAME):latest . --build-arg TARGET_PLATFORM=$(TARGET) # Build new image and automatically tag it as latest | ||
docker tag $(PREFIX)/$(REPO_NAME) $(PREFIX)/$(REPO_NAME):$(TAG) # Add the version tag to the latest image | ||
docker tag $(PREFIX)/$(REPO_NAME) ghcr.io/$(PREFIX)/$(REPO_NAME):latest # Tag latest for ghcr repository | ||
docker tag $(PREFIX)/$(REPO_NAME) ghcr.io/$(PREFIX)/$(REPO_NAME):$(TAG) # Tag the version tag for ghcr repository | ||
if ! docker buildx inspect $(BUILDER_NAME) 2> /dev/null ; then docker buildx create --name $(BUILDER_NAME) ; fi | ||
docker buildx build \ | ||
--builder=$(BUILDER_NAME) \ | ||
--platform=$(TARGET) \ | ||
--build-arg VCS_REF=$(VCS_REF) \ | ||
--build-arg BUILD_DATE=$(BUILD_DATE) \ | ||
$(BUILD_FLAGS) \ | ||
$(foreach TAG,$(DOCKER_TAGS),--tag $(TAG)) \ | ||
. | ||
|
||
push: push-docker-hub push-ghcr | ||
push: BUILD_FLAGS:=$(BUILD_FLAGS:--load=) | ||
push: BUILD_FLAGS+=--push | ||
push: image | ||
|
||
push-docker-hub: image | ||
docker push $(PREFIX)/$(REPO_NAME):latest # Push image tagged as latest to docker hub repository | ||
docker push $(PREFIX)/$(REPO_NAME):$(TAG) # Push version tagged image to docker hub repository (since this image is already pushed it will simply create or update version tag) | ||
|
||
push-ghcr: image | ||
docker push ghcr.io/$(PREFIX)/$(REPO_NAME):latest # Push image tagged as latest to ghcr repository | ||
docker push ghcr.io/$(PREFIX)/$(REPO_NAME):$(TAG) # Push version tagged image to ghcr repository (since this image is already pushed it will simply create or update version tag) | ||
|
||
clean: | ||
clean: | ||
if docker buildx inspect $(BUILDER_NAME) 2> /dev/null ; then docker buildx rm $(BUILDER_NAME) ; fi | ||
$(foreach TAG,$(DOCKER_TAGS),docker rmi -f $(TAG); ) |
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 |
---|---|---|
|
@@ -20,4 +20,4 @@ if [ -z $PLATFORM ]; then | |
exit 1 | ||
fi | ||
|
||
echo "$PLATFORM" | ||
echo "linux/$PLATFORM" |