Skip to content

Commit ab25cef

Browse files
s-zeidTheAssassin
authored andcommitted
ci: Fix building with Podman
I had two issues building with Podman: 1. `/dev/shm` did not have available space--on a host with ~16 GiB of RAM. To work around this, I added a check that at least 1 GiB of space is available or else `/dev/shm` won't be used. 2. Permission denied errors when moving binaries to `/out` when running rootlessly. The user ID inside the container was not mapping to the host user ID. Setting `PODMAN_USERNS=keep-id` solves this. The use of this environment variable instead of the equivalent `--userns` option should ensure that Docker runs are not affected by this change. (I do not override `$PODMAN_USERNS` if it is already set, so that users can easily override it if needed for their host system.) Tested on Alpine Linux edge x86_64 with Podman 3.4.4. (`apk add podman-docker` provides a shim for `docker` that invokes `podman`.)
1 parent 9a13f09 commit ab25cef

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

ci/build-binaries-and-appimage.sh

+9-1
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,16 @@ export PATH=/deps/bin:"$PATH"
1515
echo "$KEY" | md5sum
1616

1717
# we always build in a temporary directory
18-
# use RAM disk if possible
18+
# use RAM disk if possible and if enough space available
19+
USE_SHM=0
1920
if [ -d /dev/shm ] && mount | grep /dev/shm | grep -v -q noexec; then
21+
SHM_FREE_KIB_MIN=$((1 * 1024 * 1024))
22+
SHM_FREE_KIB=$(df -P -k /dev/shm | tail -n 1 | sed -e 's/ \+/ /g' | cut -d ' ' -f 4)
23+
if [[ "$SHM_FREE_KIB" != "" ]] && [ $SHM_FREE_KIB -ge $SHM_FREE_KIB_MIN ]; then
24+
USE_SHM=1
25+
fi
26+
fi
27+
if [[ "$USE_SHM" = "1" ]]; then
2028
TEMP_BASE=/dev/shm
2129
elif [ -d /docker-ramdisk ]; then
2230
TEMP_BASE=/docker-ramdisk

ci/build.sh

+1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ fi
7979
# TODO: make gnupg home available, e.g., through "-v" "$HOME"/.gnupg:/root/.gnupg
8080
# TODO: this ^ won't work since we don't build as root any more
8181
# note: we enforce using the same UID in the container as outside, so that the created files are owned by the caller
82+
env PODMAN_USERNS=${PODMAN_USERNS:-keep-id} \
8283
docker run --rm \
8384
--user "$uid" \
8485
"${common_docker_opts[@]}" \

0 commit comments

Comments
 (0)