-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathworkbench
executable file
·38 lines (32 loc) · 931 Bytes
/
workbench
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
#! /bin/sh
DIR="$(cd "$(dirname "$0")"; pwd)";
IMG=$(docker build -q $DIR/.workbench)
DOCKER_ARGS="-it"
if [ "$#" -eq 0 ]; then
CMD=bash
else
CMD="$@"
fi
if [ ! -z "$CI_PROJECT_DIR" ]; then
CONTAINER_OPTS="-v /root:/root -v /${CI_PROJECT_DIR}:/${CI_PROJECT_DIR}"
USER=root
else
CONTAINER_OPTS="-v $HOME:$HOME -it"
fi
docker run --rm \
--net host \
-v /etc/passwd:/etc/passwd \
-v /etc/group:/etc/group \
-v /tmp:/tmp \
-e HOME:${HOME} \
-e http_proxy="$http_proxy" \
-e https_proxy="$https_proxy" \
-e no_proxy="$no_proxy" \
-e CI_COMMIT_REF_NAME="$CI_COMMIT_REF_NAME" \
-e CI_COMMIT_TAG="$CI_COMMIT_REF_NAME" \
-e DOCKERHUB_USERNAME="$DOCKERHUB_USERNAME" \
-e DOCKERHUB_PASSWORD="$DOCKERHUB_PASSWORD" \
-v "${DIR}":/project \
-v /var/run/docker.sock:/var/run/docker.sock \
$CONTAINER_OPTS $IMG \
sudo -u ${USER} -E sh -c "cd ${DIR}; ${CMD}"