Make recent `makecontainerpkg` changes work with Docker

This commit is contained in:
Martchus 2023-11-10 14:11:54 +01:00
parent b7fb618581
commit 719f39092c
2 changed files with 16 additions and 3 deletions

View File

@ -2,7 +2,8 @@ FROM archlinux:base as base
MAINTAINER Martchus <martchus@gmx.net>
RUN mkdir -p /startdir /build && \
useradd -m -d /build -u 1000 -U -s /bin/bash builduser && \
groupadd -g 1000 builduser && \
useradd -m -d /build -u 1000 -g 1000 -s /bin/bash builduser && \
chown -R builduser:builduser /startdir /build && \
echo 'builduser ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers && \
pacman-key --init && \

View File

@ -19,7 +19,19 @@ else
uuid=$(cat /proc/sys/kernel/random/uuid)
name=$tool-$pkgname-$uuid
fi
cre_args=(--name "$name" --workdir "/startdir" -v "$PWD":/startdir -it --userns=keep-id:uid=1000,gid=1000)
cre_args=(--name "$name" --workdir "/startdir" -v "$PWD":/startdir -it)
cre_rm_args=(--force)
# use "builduser" that has been created via the Dockerfile
uid=1000 gid=1000
if [[ $CRE == 'podman' ]]; then
cre_args+=(--userns="keep-id:uid=$uid,gid=$gid")
cre_rm_args+=(--time 0)
else
cre_args+=(--user="$uid:$gid")
# caveat: In contrast to Podman this gives a wrong gid for newly created files by
# default. Maybe it would help to pass `--userns-remap=…` to `dockerd`.
fi
# parse arguments
script_args= read_script_args=
@ -77,7 +89,7 @@ fi
# stop and remove container unless we want to keep it for debugging
[[ $ec == 0 && $DEBUG == on-failure || -z $DEBUG ]] && \
"$cre" container rm --force --time 0 "$name"
"$cre" container rm "${cre_rm_args[@]}" "$name"
# log message about commands to use for investigation
[[ $ec != 0 ]] && [[ $DEBUG ]] && echo \