From f052709112bcda89e7057e39212f9f9e46170bf3 Mon Sep 17 00:00:00 2001 From: Kai Lueke Date: Thu, 30 Jun 2022 13:01:47 +0200 Subject: [PATCH] Support building with Podman instead of Docker When /usr/bin/docker is a wrapper for podman (as common no Fedora), Podman will be used which requires the full image name including the registry. It does not require the chown step, because this results in the files being owned by a temporary mapped ID due to the user namespace in rootless mode (which is the default unless Podman is run by the root user) - make the chown a no-op by using UID/GID 0. --- Dockerfile | 4 ++-- Makefile | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 07fc0d72..860c6ce6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:alpine +FROM docker.io/golang:alpine WORKDIR /root USER root @@ -8,4 +8,4 @@ RUN apk add musl-dev gcc libtool m4 autoconf g++ make libblkid util-linux-dev gi ADD ./scripts/build-static.sh /build-static.sh RUN chmod +x /build-static.sh -CMD ["/bin/sh"] \ No newline at end of file +CMD ["/bin/sh"] diff --git a/Makefile b/Makefile index 06d26d5a..e6ef9ad2 100644 --- a/Makefile +++ b/Makefile @@ -4,8 +4,11 @@ SHELL := bash IMAGE_TAG = garm-build +USER_ID=$(shell (docker --version | grep -q podman) && echo "0" || shell id -u) +USER_GROUP=$(shell (docker --version | grep -q podman) && echo "0" || shell id -g) + build-static: @echo Building garm docker build --tag $(IMAGE_TAG) . - docker run --rm -e USER_ID="$(shell id -u)" -e USER_GROUP="$(shell id -g)" -v $(PWD):/build/garm $(IMAGE_TAG) /build-static.sh + docker run --rm -e USER_ID=$(USER_ID) -e USER_GROUP=$(USER_GROUP) -v $(PWD):/build/garm $(IMAGE_TAG) /build-static.sh @echo Binaries are available in $(PWD)/bin