diff options
author | 2021-02-03 12:12:20 -0800 | |
---|---|---|
committer | 2021-02-04 16:19:45 -0800 | |
commit | d274d25c2da31fd6cf5b8a86f81d9d79c4545e8c (patch) | |
tree | 95fee110c8c7071c875e7db9bda22a068d9830e6 /scripts/dev.sh | |
parent | Categorise and sort scripts in Pipfile (diff) |
Replace dev.sh with Docker Compose
Managing development containers through Docker Compose is convenient.
However, it isn't quite flexible enough to facilitate both development
and normal use. It's not really worth accommodating the latter since
the container gets pushed to a registry and that's the intended way to
run the service. Anyone that is checking out the repository and
therefore has access to the compose file is likely a developer, not a
user.
Diffstat (limited to 'scripts/dev.sh')
-rwxr-xr-x | scripts/dev.sh | 65 |
1 files changed, 0 insertions, 65 deletions
diff --git a/scripts/dev.sh b/scripts/dev.sh deleted file mode 100755 index efbd93a..0000000 --- a/scripts/dev.sh +++ /dev/null @@ -1,65 +0,0 @@ -#!/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 ghcr.io/python-discord/snekbox-venv:dev..." - - docker build \ - -t ghcr.io/python-discord/snekbox-venv:dev \ - -f Dockerfile \ - --build-arg DEV=1 \ - --target venv \ - -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..." - - # shellcheck disable=SC2086 - 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" \ - --volume "${PWD}":"${PWD}" \ - --workdir "${PWD}"\ - --entrypoint /bin/bash \ - ghcr.io/python-discord/snekbox-venv:dev \ - >/dev/null \ - -# Execute the given command(s) -docker exec -it snekbox_test /bin/bash "$@" - -# 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 |