-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathworkbench.codespaces
executable file
·51 lines (40 loc) · 1.36 KB
/
workbench.codespaces
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
#!/bin/sh
set -e
DIR="$(cd "$(dirname "$0")" >/dev/null 2>&1; pwd -P)"
WORKBENCH_DOCKER_NETWORK="kind"
if [ "$#" -eq 0 ]; then
CMD=bash
else
CMD="$@"
fi
SUDO="sudo -u ${USER} -E"
K8S_CONFIG="KUBECONFIG=\"$DIR/.kubeconfig\""
# don't exit on docker errors, we want to cleanup after execution
set +e
# Build the workbench docker container without using it directly.
# This way we have the command line output of the build process
echo Build workbench image
docker build -f workbench.dockerfile .
# Build the workbench docker container again, but with -q parameter.
# The build is finished immediately, as everything is already in cache.
# The result is the hash of the container, which is used to start it.
CONTAINER_HASH=$(docker build -q -f workbench.dockerfile .)
# TimeStamp: seconds since epoch
CURRENT_TIME="$(date +%s000)"
echo Start workbench container
docker run --rm \
--pull=never \
-e DOCKER_BUILDKIT=1 \
-e http_proxy="$http_proxy" \
-e https_proxy="$https_proxy" \
-e no_proxy="$no_proxy" \
-v /etc/passwd:/etc/passwd:ro \
-v /etc/group:/etc/group:ro \
-v /var/run/docker.sock:/var/run/docker.sock \
--network $WORKBENCH_DOCKER_NETWORK \
--pid host \
--name escape_room_workbench-$CURRENT_TIME \
-v $HOME:$HOME \
-v $DIR:$DIR \
-it $CONTAINER_HASH \
$SUDO sh -c "cd $DIR; HOME=$HOME $K8S_CONFIG $CMD"