-
Notifications
You must be signed in to change notification settings - Fork 5.9k
/
Copy pathexec.sh
executable file
·50 lines (40 loc) · 931 Bytes
/
exec.sh
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
#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "$0")"
# Ensure submodules are cloned and up to date.
git submodule update --init
container_name=code-server-dev
enter() {
echo "--- Entering $container_name"
docker exec -it $container_id /bin/bash
}
run() {
echo "--- Spawning $container_name"
container_id=$(docker run \
-it \
--privileged \
--name $container_name \
"-v=$PWD:/code-server" \
"-w=/code-server" \
"-p=8080:8080" \
$([[ -t 0 ]] && echo -it || true) \
-d \
$container_name)
}
build() {
echo "--- Building $container_name"
cd ../../ && docker build -t $container_name -f ./ci/dev-image/Dockerfile . > /dev/null
}
set +e
container_id=$(docker container inspect --format="{{.Id}}" $container_name 2> /dev/null)
if [ $? -eq "0" ]; then
set -e
echo "-- Starting container"
docker start $container_id > /dev/null
enter
exit 0
fi
set -e
build
run
enter