Docker Buildx on Manjaro
Posted on
Catatan kecil ketika aku nyobain docker buildx di Laptop dengan OS Manjaro. Aku mencoba build image untuk arm64 dan amd64. Berikut ini ada langkah yang aku tempuh:
Pertama, aku install qemu-user-static ikutin guide ini, ringkasannya begini:
$ uname -m
x86_64
$ docker run --rm -t arm64v8/ubuntu uname -m
standard_init_linux.go:211: exec user process caused "exec format error"
$ docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
$ docker run --rm -t arm64v8/ubuntu uname -m
aarch64
Selanjutnya, aku bikin builder instance
$ docker buildx create --name multiarch --driver docker-container --use
$ docker buildx inspect --bootstrap
# output:
Name: multiarch
Driver: docker-container
Nodes:
Name: multiarch0
Endpoint: unix:///var/run/docker.sock
Status: running
Platforms: linux/amd64, linux/amd64/v2, linux/amd64/v3, linux/386, linux/arm64, linux/riscv64, linux/ppc64le, linux/s390x, linux/mips64le, linux/mips64
Terakhir, aku coba build image
$ cd projects/personal-blog
# Target arm64
$ docker buildx build --load -t sumarsono/personal-blog:latest-arm64 --platform linux/arm64 .
# Target amd64
$ docker buildx build --load -t sumarsono/personal-blog:latest-amd64 --platform linux/amd64 .
Check hasil build
REPOSITORY TAG IMAGE ID CREATED SIZE
sumarsono/personal-blog latest-amd64 545e2a6a7c65 24 minutes ago 56.1MB
sumarsono/personal-blog latest-arm64 4c38e55cc0b9 29 minutes ago 54.7MB
Dockerfile yang aku coba:
# build the website
FROM klakegg/hugo:latest-ext AS builder
COPY . /site
WORKDIR /site
RUN hugo --minify
# publish the build result
FROM caddy:2-alpine AS webserver
LABEL maintainer="Sumarsono [email protected]>"
COPY --from=builder /site/public /usr/share/caddy