From 9cf12f6b3703af7a4f2f35b890e0cff30ed3be1b Mon Sep 17 00:00:00 2001 From: Carlton Gibson Date: Wed, 19 Jun 2019 14:12:04 +0200 Subject: [PATCH] Add Dockerfile and wrapper for `docker run`. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds a basic Dockerfile. Build with: docker build -t daphne . The `-t daphne` gives the image the name `daphne` so you can run it easily later. Do this once to begin, and if you alter the `venv`. Then you can `docker run` to exectute `pytest`: ``` docker run --rm \ --mount type=bind,source=`pwd`,target=/src \ daphne ``` This mounts the Daphne source code from your checkout into the container, so you can test you latest code, rather than the version you built the container with. In addition the `docker-tests.sh` helper just wraps that `docker run` command, and deletes any .pyc files, so you don’t get a conflict between the host and container. --- Dockerfile | 9 +++++++++ docker-tests.sh | 6 ++++++ 2 files changed, 15 insertions(+) create mode 100644 Dockerfile create mode 100755 docker-tests.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..7eb8329 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM python:3.7 + +RUN mkdir /src +WORKDIR /src +ADD . /src/ + +RUN pip install -e .[tests] + +CMD ["pytest"] diff --git a/docker-tests.sh b/docker-tests.sh new file mode 100755 index 0000000..0450d09 --- /dev/null +++ b/docker-tests.sh @@ -0,0 +1,6 @@ +#! /bin/bash +find . -name "*.pyc" -delete + +docker run --rm \ +--mount type=bind,source=`pwd`,target=/src \ +daphne