Last active
May 3, 2021 20:56
-
-
Save alvarogg777/53361d125cbe05cc6c70ff0b69acde60 to your computer and use it in GitHub Desktop.
Buildah-multi 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
ARG arch= | |
FROM alpine:3.13.5 | |
ENV KUSTOMIZE_VER 4.1.2 | |
ENV KUBECTL_VER 1.19.2 | |
RUN echo $arch | |
RUN apk --no-cache add curl gettext | |
RUN export arch=`ls -1 /lib/ | grep 64 | sed "s/64.*/64/" |cut -f3 -d"-" | grep 64 |head -n1`; if [ $arch = "aarch64" ]; then arch="arm64"; elif [ $arch = "x86_64" ]; then arch="amd64"; else arch=$arch; fi; curl -L https://storage.googleapis.com/kubernetes-release/release/v${KUSTOMIZE_VER}/bin/linux/$arch/kubectl -o /usr/bin/kustomize \ | |
&& chmod +x /usr/bin/kustomize && curl -L https://storage.googleapis.com/kubernetes-release/release/v${KUBECTL_VER}/bin/linux/$arch/kubectl -o /usr/bin/kubectl \ | |
&& chmod +x /usr/bin/kubectl | |
RUN apk add -U git |
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
project=`pwd | sed 's:.*/::'| tr -d '\012\015' ` | |
image_name=alvarogg777/$(project) | |
architectures=arm64,amd64 | |
architectures_list=$(shell echo $(architectures) | tr "," "\n") | |
# image_tag=$(shell date -I) | |
image_tag=latest | |
target=$(image_name):$(image_tag) | |
all: build push | |
build: | |
@echo "Building image:" | |
# echo $(architectures_list) | |
# cd $(project); | |
buildah manifest create $(target) ; \ | |
for arch in $(architectures_list); do \ | |
arch_image=$(image_name):$(image_tag)-$$arch ; \ | |
# buildah bud -v /mnt/ssd/gitlab_alvarogg777/helm-charts/allinone/argo-combined-app:/src -t $$arch_image --arch $$arch . ; \ | |
buildah bud -t $$arch_image --arch $$arch . ; \ | |
buildah push --authfile $(HOME)/.docker/config.json $$arch_image ; \ | |
buildah manifest add $(target) $$arch_image ; \ | |
done | |
@echo Manifest creation done | |
push: | |
@echo "Pushing image:" | |
buildah manifest push --authfile $(HOME)/.docker/config.json $(target) docker://$(target) | |
@echo Manifest creation done | |
test: | |
@echo "Running container:" | |
podman run --rm -p 8080:8080 $(PREFIX):$(TAG) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment