blob: 408ce2eb3a5906ef28af083ee02f3f76ff880237 (
plain) (
blame)
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
53
54
55
56
57
58
59
60
61
62
63
64
|
#!/usr/bin/env sh
# Sets up a development environment and runs a shell in a docker container.
# Usage: dev.sh [--build [--clean]] [bash_args ...]
if [ "$1" = "--build" ]; then
shift
printf "Building pythondiscord/snekbox-venv:dev..."
docker build \
-t pythondiscord/snekbox-venv:dev \
-f docker/venv.Dockerfile \
--build-arg DEV=1 \
-q \
. \
>/dev/null \
&& printf " done!\n" || exit "$?"
if [ "$1" = "--clean" ]; then
shift
dangling_imgs=$(docker images -f "dangling=true" -q)
if [ -n "${dangling_imgs}" ]; then
printf "Removing dangling images..."
docker rmi $dangling_imgs >/dev/null \
&& printf " done!\n" || exit "$?"
fi
fi
fi
# Keep the container up in the background so it doesn't have to be restarted
# for the ownership fix.
# The volume is mounted to same the path in the container as the source
# directory on the host to ensure coverage can find the source files.
docker run \
--tty \
--detach \
--name snekbox_test \
--privileged \
--hostname pdsnk-dev \
--ipc="none" \
-e PYTHONDONTWRITEBYTECODE=1 \
-e PIPENV_PIPFILE="/snekbox/Pipfile" \
-e BASH_ENV="${PWD}/scripts/.profile" \
--volume "${PWD}":"${PWD}" \
--workdir "${PWD}"\
--entrypoint /bin/bash \
pythondiscord/snekbox-venv:dev \
>/dev/null \
# Execute the given command(s)
docker exec -it snekbox_test /bin/bash --rcfile "${PWD}/scripts/.profile" "$@"
# Fix ownership of coverage file
# BusyBox doesn't support --reference for chown
docker exec \
-it \
-e CWD="${PWD}" \
snekbox_test \
/bin/bash \
-c 'chown "$(stat -c "%u:%g" "${CWD}")" "${CWD}/.coverage"'
docker rm -f snekbox_test >/dev/null # Stop and remove the container
|