Skip to content

Commit 07d4bf3

Browse files
committed
fix: multi arch
1 parent c60b38f commit 07d4bf3

File tree

3 files changed

+51
-6
lines changed

3 files changed

+51
-6
lines changed

.editorconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# EditorConfig is awesome: https://EditorConfig.org
2+
3+
# top-most EditorConfig file
4+
root = true
5+
6+
[*]
7+
indent_style = space
8+
indent_size = 4
9+
end_of_line = lf
10+
charset = utf-8
11+
trim_trailing_whitespace = false
12+
insert_final_newline = false
13+
14+
[Makefile]
15+
indent_style = tab

Dockerfile

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
#syntax=docker/dockerfile:1.3-labs
2+
13
FROM alpine
4+
ARG TARGETARCH
25

36
# Ignore to update versions here
47
# docker build --no-cache --build-arg KUBECTL_VERSION=${tag} --build-arg HELM_VERSION=${helm} --build-arg KUSTOMIZE_VERSION=${kustomize_version} -t ${image}:${tag} .
@@ -9,12 +12,12 @@ ARG KUSTOMIZE_VERSION=v4.5.5
912
# Install helm (latest release)
1013
# ENV BASE_URL="https://storage.googleapis.com/kubernetes-helm"
1114
ENV BASE_URL="https://get.helm.sh"
12-
ENV TAR_FILE="helm-v${HELM_VERSION}-linux-amd64.tar.gz"
15+
ENV TAR_FILE="helm-v${HELM_VERSION}-linux-${TARGETARCH}.tar.gz"
1316
RUN apk add --update --no-cache curl ca-certificates bash git && \
1417
curl -sL ${BASE_URL}/${TAR_FILE} | tar -xvz && \
15-
mv linux-amd64/helm /usr/bin/helm && \
18+
mv linux-${TARGETARCH}/helm /usr/bin/helm && \
1619
chmod +x /usr/bin/helm && \
17-
rm -rf linux-amd64
20+
rm -rf linux-${TARGETARCH}
1821

1922
# add helm-diff
2023
RUN helm plugin install https://github.com/databus23/helm-diff && rm -rf /tmp/helm-*
@@ -26,13 +29,13 @@ RUN helm plugin install https://github.com/quintush/helm-unittest && rm -rf /tmp
2629
RUN helm plugin install https://github.com/chartmuseum/helm-push && rm -rf /tmp/helm-*
2730

2831
# Install kubectl (same version of aws esk)
29-
RUN curl -sLO https://storage.googleapis.com/kubernetes-release/release/v${KUBECTL_VERSION}/bin/linux/amd64/kubectl && \
32+
RUN curl -sLO https://storage.googleapis.com/kubernetes-release/release/v${KUBECTL_VERSION}/bin/linux/${TARGETARCH}/kubectl && \
3033
mv kubectl /usr/bin/kubectl && \
3134
chmod +x /usr/bin/kubectl
3235

3336
# Install kustomize (latest release)
34-
RUN curl -sLO https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2F${KUSTOMIZE_VERSION}/kustomize_${KUSTOMIZE_VERSION}_linux_amd64.tar.gz && \
35-
tar xvzf kustomize_${KUSTOMIZE_VERSION}_linux_amd64.tar.gz && \
37+
RUN curl -sLO https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2F${KUSTOMIZE_VERSION}/kustomize_${KUSTOMIZE_VERSION}_linux_${TARGETARCH}.tar.gz && \
38+
tar xvzf kustomize_${KUSTOMIZE_VERSION}_linux_${TARGETARCH}.tar.gz && \
3639
mv kustomize /usr/bin/kustomize && \
3740
chmod +x /usr/bin/kustomize
3841

Makefile

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
IMAGE?=kameshsampath/kube-dev-tools
2+
TAG?=latest
3+
SHELL := bash
4+
CURRENT_DIR = $(shell pwd)
5+
ENV_FILE := $(CURRENT_DIR)/.env
6+
BUILDER=buildx-multi-arch
7+
DOCKER_FILE=$(CURRENT_DIR)/Dockerfile
8+
9+
prepare-buildx: ## Create buildx builder for multi-arch build, if not exists
10+
docker buildx inspect $(BUILDER) || docker buildx create --name=$(BUILDER) --driver=docker-container --driver-opt=network=host
11+
12+
build-tools: ## Build tools image locally
13+
docker build --tag=$(IMAGE):$(shell svu next) -f $(DOCKER_FILE) .
14+
docker tag $(IMAGE):$(shell svu next) $(IMAGE):$(TAG)
15+
16+
push-tools: prepare-buildx ## Build & Upload extension image to hub. Do not push if tag already exists: TAG=$(svu c) make push-extension
17+
docker pull $(IMAGE):$(shell svu c) && echo "Failure: Tag already exists" || docker buildx build --push --builder=$(BUILDER) --platform=linux/amd64,linux/arm64 --build-arg TAG=$(shell svu c) --tag=$(IMAGE):$(shell svu c) -f $(DOCKER_FILE) .
18+
19+
release:
20+
git tag "$(shell svu next)"
21+
git push --tags
22+
23+
help: ## Show this help
24+
@echo Please specify a build target. The choices are:
25+
@grep -E '^[0-9a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "$(INFO_COLOR)%-30s$(NO_COLOR) %s\n", $$1, $$2}'
26+
27+
.PHONY: bin build-plugin push-plugin help

0 commit comments

Comments
 (0)