Add Dockerfile and wrapper for docker run.

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.
This commit is contained in:
Carlton Gibson 2019-06-19 14:12:04 +02:00
parent ffd949f2ce
commit 9cf12f6b37
2 changed files with 15 additions and 0 deletions

9
Dockerfile Normal file
View File

@ -0,0 +1,9 @@
FROM python:3.7
RUN mkdir /src
WORKDIR /src
ADD . /src/
RUN pip install -e .[tests]
CMD ["pytest"]

6
docker-tests.sh Executable file
View File

@ -0,0 +1,6 @@
#! /bin/bash
find . -name "*.pyc" -delete
docker run --rm \
--mount type=bind,source=`pwd`,target=/src \
daphne