-
Notifications
You must be signed in to change notification settings - Fork 8
/
fingertip-containerized
executable file
·52 lines (44 loc) · 1.28 KB
/
fingertip-containerized
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash
set -ue
DISTRO=fedora:32
FINGERTIPDIR=$(realpath $(dirname "$0"))
if command -v podman > /dev/null; then
BACKEND=podman
elif command -v docker > /dev/null; then
BACKEND=docker
else
echo "Neither podman or docker were found, sorry"
fi
EXTRA_OPTS=""
if [[ -n "${FINGERTIP_DEBUG+x}" ]] && [[ "$FINGERTIP_DEBUG" == 1 ]]; then
EXTRA_OPTS="-e FINGERTIP_DEBUG=1"
fi
mkdir -p ~/.cache/fingertip
MARKER=$FINGERTIPDIR/.$BACKEND-build-marker
if [[ ! -e "$MARKER" || -n "$(find "$FINGERTIPDIR"/* -newer "$MARKER")" ]]
then
echo "Trying to run $DISTRO with $BACKEND for starters..."
if ! $BACKEND run -it $DISTRO true; then
echo "$($BACKEND run -it $DISTRO true) fails, fix this"
exit 1
fi
echo "Building a fingertip image for $BACKEND..."
pushd "$FINGERTIPDIR"
$BACKEND build -t fingertip .
popd
touch "$MARKER"
fi
echo "Trying a limited version of fingertip inside $BACKEND..."
# --device /dev/kvm didn't work out, so --privileged
exec $BACKEND run \
--rm \
--tmpfs /tmp:rw,size=6G \
--volume "$(pwd):/cwd:z" \
--volume "$FINGERTIPDIR:/containerized-fingertip:z" \
--volume ~/.cache/fingertip:/user-home/.cache/fingertip:z \
--label=false \
--privileged \
--userns=keep-id --user $(id -u):$(id -g) \
$EXTRA_OPTS \
-it fingertip \
/usr/bin/python3 /containerized-fingertip "$@"