diff options
-rw-r--r-- | Pipfile | 24 | ||||
-rw-r--r-- | scripts/.profile (renamed from docker/.profile) | 0 | ||||
-rwxr-xr-x | scripts/dev.sh | 45 |
3 files changed, 46 insertions, 23 deletions
@@ -40,29 +40,7 @@ snekbox = """ --access-logfile - \ snekbox.api.app """ -build-venv-dev = """ - docker build \ - -t pythondiscord/snekbox-venv:dev \ - -f docker/venv.Dockerfile - --build-arg DEV=1 \ - . -""" -devsh = """ - /usr/bin/env sh -c ' - docker run \ - -it \ - --rm \ - --privileged \ - --network host \ - -h pdsnk-dev \ - -e PIPENV_PIPFILE="/snekbox/Pipfile" \ - -e ENV="/snekbox-local/docker/.profile" \ - -v "$(pwd)":/snekbox-local \ - -w "/snekbox-local" \ - --entrypoint /bin/ash \ - pythondiscord/snekbox-venv:dev - ' -""" +devsh = "scripts/dev.sh" buildbox = "docker build -t pythondiscord/snekbox:latest -f docker/Dockerfile ." pushbox = "docker push pythondiscord/snekbox:latest" buildboxbase = "docker build -t pythondiscord/snekbox-base:latest -f docker/base.Dockerfile ." diff --git a/docker/.profile b/scripts/.profile index 415e4f6..415e4f6 100644 --- a/docker/.profile +++ b/scripts/.profile diff --git a/scripts/dev.sh b/scripts/dev.sh new file mode 100755 index 0000000..490021f --- /dev/null +++ b/scripts/dev.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env sh + +# Sets up a development environment and runs a shell in a docker container. +# Usage: dev.sh [--build [--clean]] [ash_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 + +docker run \ + -it \ + --rm \ + --privileged \ + --network host \ + -h pdsnk-dev \ + -e PYTHONDONTWRITEBYTECODE=1 \ + -e PIPENV_PIPFILE="/snekbox/Pipfile" \ + -e ENV="/snekbox-local/scripts/.profile" \ + -v "${PWD}":/snekbox-local \ + -w "/snekbox-local" \ + --entrypoint /bin/ash \ + pythondiscord/snekbox-venv:dev \ + "$@" |