Comprobado en gentoo que van docker y podman
This commit is contained in:
parent
6fe64c1d85
commit
046c267e13
1 changed files with 24 additions and 8 deletions
|
|
@ -1,6 +1,10 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
set -x
|
||||||
|
|
||||||
|
BUILDCACHE=./.build-container-cache
|
||||||
|
|
||||||
|
|
||||||
detect_container(){
|
detect_container(){
|
||||||
|
|
||||||
|
|
@ -20,11 +24,15 @@ detect_container(){
|
||||||
}
|
}
|
||||||
|
|
||||||
clean_build_cache(){
|
clean_build_cache(){
|
||||||
|
if [ -d $BUILDCACHE ]; then rm -r $BUILDCACHE; fi
|
||||||
|
if [ -d .dart_tool ]; then rm -r .dart_tool; fi
|
||||||
|
if [ -d build ]; then rm -r build; fi
|
||||||
$DOCKER builder prune --all --force
|
$DOCKER builder prune --all --force
|
||||||
}
|
}
|
||||||
|
|
||||||
build_image(){
|
build_image(){
|
||||||
$DOCKER build --build-arg USER_ID=$(id -u) --build-arg GROUP_ID=$(id -g) --progress=plain -t d4rt-formulas-builder -f Dockerfile .
|
# docker doesnt support --progress=PLAIN
|
||||||
|
$DOCKER build --build-arg USER_ID=$(id -u) --build-arg GROUP_ID=$(id -g) -t d4rt-formulas-builder -f Dockerfile .
|
||||||
}
|
}
|
||||||
|
|
||||||
graphic_options(){
|
graphic_options(){
|
||||||
|
|
@ -37,12 +45,13 @@ graphic_options(){
|
||||||
[ "$XDG_SESSION_TYPE" = "wayland" ] || [ "$WAYLAND_DISPLAY" != "" ]
|
[ "$XDG_SESSION_TYPE" = "wayland" ] || [ "$WAYLAND_DISPLAY" != "" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
if is_x11
|
# DISPLAY IS ALSO DEFINED IN WAYLAND, SO TEST WAYLAND FIRST
|
||||||
|
if is_wayland
|
||||||
|
then
|
||||||
|
echo "--env=XDG_RUNTIME_DIR=/run/user/$(id -u) --volume=/run/user/$(id -u)/$WAYLAND_DISPLAY:/run/user/$(id -u)/$WAYLAND_DISPLAY --group-add=video"
|
||||||
|
elif is_x11
|
||||||
then
|
then
|
||||||
echo "--env DISPLAY=$DISPLAY --volume /tmp/.X11-unix:/tmp/.X11-unix --security-opt=label=disable"
|
echo "--env DISPLAY=$DISPLAY --volume /tmp/.X11-unix:/tmp/.X11-unix --security-opt=label=disable"
|
||||||
elif is_wayland
|
|
||||||
then
|
|
||||||
echo "--env=XDG_RUNTIME_DIR=/run/user/$(id -u) --volume=/run/user/$(id -u)/wayland:/run/user/$(id -u)/wayland --group-add=video"
|
|
||||||
else
|
else
|
||||||
echo "WARNING: no graphic environment" 1>&2
|
echo "WARNING: no graphic environment" 1>&2
|
||||||
fi
|
fi
|
||||||
|
|
@ -64,18 +73,25 @@ spi_options(){
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
docker_options(){
|
||||||
|
if [ "$DOCKER" = "podman" ]
|
||||||
|
then
|
||||||
|
printf " %s " "--userns=keep-id"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
exec_in_container(){
|
exec_in_container(){
|
||||||
SPIOPTIONS=$(spi_options)
|
local SPIOPTIONS=$(spi_options)
|
||||||
local GRAPHICOPTIONS=$(graphic_options)
|
local GRAPHICOPTIONS=$(graphic_options)
|
||||||
local BUILDCACHE=./.build-container-cache
|
local DOCKEROPTIONS=$(docker_options)
|
||||||
mkdir -p $BUILDCACHE
|
mkdir -p $BUILDCACHE
|
||||||
|
|
||||||
$DOCKER run \
|
$DOCKER run \
|
||||||
-it \
|
-it \
|
||||||
--userns=keep-id \
|
|
||||||
--user $(id -u):$(id -g) \
|
--user $(id -u):$(id -g) \
|
||||||
--init \
|
--init \
|
||||||
--rm \
|
--rm \
|
||||||
|
$DOCKEROPTIONS \
|
||||||
$GRAPHICOPTIONS \
|
$GRAPHICOPTIONS \
|
||||||
$SPIOPTIONS \
|
$SPIOPTIONS \
|
||||||
-p ${WEBPORT:-8081}:8081 \
|
-p ${WEBPORT:-8081}:8081 \
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue