diff options
author | 2019-06-06 11:16:54 -0700 | |
---|---|---|
committer | 2019-06-22 13:35:49 -0700 | |
commit | cbc375b4a84aa07554b31b1608a82091ba671a58 (patch) | |
tree | 0d0f0bab93f910f897acfe08957ab1b6189a2c2d | |
parent | Use a custom Gunicorn access log format (diff) |
Add support for development to Docker images
* Venv image can sync dev dependencies
* Copy tests to image
* Add a Pipenv script for running a development shell in a container
* Add Pipenv scripts for building dev images
-rw-r--r-- | .dockerignore | 1 | ||||
-rw-r--r-- | Pipfile | 34 | ||||
-rw-r--r-- | docker-compose.yml | 3 | ||||
-rw-r--r-- | docker/venv.Dockerfile | 3 |
4 files changed, 34 insertions, 7 deletions
diff --git a/.dockerignore b/.dockerignore index 2a5ccec..7dc3fed 100644 --- a/.dockerignore +++ b/.dockerignore @@ -3,6 +3,7 @@ # Make exceptions for what's needed !snekbox +!tests !Pipfile !Pipfile.lock !LICENSE @@ -32,14 +32,36 @@ precommit = "pre-commit install" test = "pytest tests --cov . --cov-report term-missing -v" report = "pytest tests --cov . --cov-report=html" snekbox = """ - gunicorn - -w 2 - -b 0.0.0.0:8060 - --logger-class snekbox.GunicornLogger - --access-logformat '%(m)s %(U)s%(q)s %(s)s %(b)s %(L)ss' - --access-logfile - + gunicorn \ + -w 2 \ + -b 0.0.0.0:8060 \ + --logger-class snekbox.GunicornLogger \ + --access-logformat '%(m)s %(U)s%(q)s %(s)s %(b)s %(L)ss' \ + --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" \ + -v "$(pwd)":/snekbox-local \ + -w "/snekbox-local" \ + --entrypoint /bin/sh \ + pythondiscord/snekbox-venv:dev + ' +""" 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-compose.yml b/docker-compose.yml index 1fe8e39..d071a71 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,3 +6,6 @@ services: image: pythondiscord/snekbox:latest network_mode: "host" init: true + build: + context: . + dockerfile: docker/Dockerfile diff --git a/docker/venv.Dockerfile b/docker/venv.Dockerfile index 61aba58..85188fd 100644 --- a/docker/venv.Dockerfile +++ b/docker/venv.Dockerfile @@ -1,5 +1,6 @@ FROM pythondiscord/snekbox-base:latest +ARG DEV ENV PIP_NO_CACHE_DIR=false \ PIPENV_DONT_USE_PYENV=1 \ PIPENV_HIDE_EMOJIS=1 \ @@ -9,4 +10,4 @@ ENV PIP_NO_CACHE_DIR=false \ COPY Pipfile Pipfile.lock /snekbox/ WORKDIR /snekbox -RUN pipenv sync +RUN if [ -n "${DEV}" ]; pipenv sync --dev; then pipenv sync; fi |