gluon/scripts/container.sh
Hannes Fuchs f0528f835f
Support non default UID/GID for build container
Set the current UID and GID of the executing user as build arguments for
the build of the container, so that environments with other UIDs and GIDs
than 1000 are supported.
2023-04-18 21:28:32 +02:00

25 lines
791 B
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
# move into base directory, in case this script is not executed via `make container`
cd "$(dirname "$0")/.."
# normalize branch name to reflect a valid image name
BRANCH=$(git branch --show-current 2>/dev/null | sed 's/[^a-z0-9-]/_/ig')
TAG="gluon:${BRANCH:-latest}"
if [ "$(command -v podman)" ]
then
podman build --build-arg DGID="$(id -g)" --build-arg DUID="$(id -u)" -t "${TAG}" contrib/docker
podman run -it --rm --userns=keep-id --volume="$(pwd):/gluon" "${TAG}"
elif [ "$(command -v docker)" ]
then
docker build --build-arg DGID="$(id -g)" --build-arg DUID="$(id -u)" -t "${TAG}" contrib/docker
docker run -it --rm --volume="$(pwd):/gluon" "${TAG}"
else
1>&2 echo "Please install either podman or docker. Exiting" >/dev/null
exit 1
fi