diff --git a/Makefile b/Makefile index ed14759..c9584ec 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ REGISTRY=registry.monotremata.xyz PLATFORMS=linux/amd64,linux/arm64 -IMAGES=agate mpd pleroma rainloop tor transmission webdav +IMAGES=agate buildx-qemu mpd pleroma rainloop tor transmission webdav .PHONY: all $(IMAGES) @@ -12,6 +12,9 @@ BUILDX=docker buildx build --platform $(PLATFORMS) --tag $(REGISTRY)/$@ --push $ agate: $(BUILDX) +buildx-qemu: + $(BUILDX) + mpd: $(BUILDX) diff --git a/README.md b/README.md index 9f63490..ca34b39 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ docker registry. ## Currently implemented images: * agate +* buildx-qemu (image I use to build the other images in my CI/CD) * mpd * pleroma * rainloop @@ -23,6 +24,12 @@ docker registry. * transmission * webdav (really simple nginx + `nginx-mod-http-dav-ext` image) +## Create buildx driver + +```sh +docker buildx create --use +``` + ## Enable multi-arch execution ```sh diff --git a/buildx-qemu/Dockerfile b/buildx-qemu/Dockerfile new file mode 100644 index 0000000..a47373c --- /dev/null +++ b/buildx-qemu/Dockerfile @@ -0,0 +1,30 @@ +FROM debian:bullseye-slim + +ARG TARGETARCH + +ENV DOCKER_URL=https://download.docker.com/linux/debian +ENV GPG_FILE=/etc/apt/keyrings/docker.gpg +ENV DEBIAN_VERSION=bullseye + +RUN apt-get update && \ + apt-get install -y \ + ca-certificates \ + curl \ + gnupg && \ + rm -rf /var/lib/apt/lists/* && \ + mkdir -p /etc/apt/keyrings && \ + curl -fsSL "$DOCKER_URL/gpg" | gpg --dearmor -o "$GPG_FILE" && \ + echo "deb [arch=$TARGETARCH signed-by=$GPG_FILE] $DOCKER_URL $DEBIAN_VERSION stable" > \ + /etc/apt/sources.list.d/docker.list && \ + apt-get update && \ + apt-get install -y \ + binfmt-support \ + docker-ce-cli \ + make \ + qemu-user-static && \ + rm -rf /var/lib/apt/lists/* + +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/buildx-qemu/Makefile b/buildx-qemu/Makefile new file mode 100644 index 0000000..2a8ed67 --- /dev/null +++ b/buildx-qemu/Makefile @@ -0,0 +1,29 @@ +IMG_NAME=buildx-qemu +REGISTRY=registry.monotremata.xyz +IMG=$(REGISTRY)/$(IMG_NAME) +PLATFORMS=linux/amd64,linux/arm64 + +.PHONY: build push buildx + +ARCH=$(shell uname -m) + +ifeq ($(ARCH),x86_64) + TARGETARCH=amd64 +else ifeq ($(ARCH),aarch64) + TARGETARCH=arm64 +else + TARGETARCH=amd64 +endif + +build: Dockerfile entrypoint.sh + docker build -t $(IMG) --build-arg TARGETARCH=$(TARGETARCH) . + +push: build + docker image push $(IMG) + +buildx: Dockerfile entrypoint.sh + docker buildx build \ + --platform $(PLATFORMS) \ + --tag $(IMG) \ + --push \ + . diff --git a/buildx-qemu/entrypoint.sh b/buildx-qemu/entrypoint.sh new file mode 100644 index 0000000..f6e1b49 --- /dev/null +++ b/buildx-qemu/entrypoint.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +update-binfmts --enable +docker buildx create --use +docker buildx inspect --bootstrap + +exec "$@"