Skip to content

Commit b859443

Browse files
Merge pull request #129 from elliottmurray/docker
Docker support for builds
2 parents 5a6acaf + 9b83da7 commit b859443

File tree

6 files changed

+102
-1
lines changed

6 files changed

+102
-1
lines changed

docker/README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Introduction
2+
3+
This is for contributors who want to make changes and test for all different versions of python currently supported. If you don't want to set up and install all the different python versions locally (and there are some difficulties with that) you can just run them in docker using containers.
4+
5+
# Setup
6+
7+
To build a container say for python 3.6 change to the root directory of the project and run
8+
9+
```bash
10+
docker build -t pactfoundation:python36 -f docker/py36.Dockerfile .
11+
```
12+
13+
And then to run you will need:
14+
15+
```bash
16+
docker run -it -v `pwd`:/home pactfoundation:python36
17+
```
18+
19+
If you need to debug you can change the command to:
20+
21+
```bash
22+
docker run -it -v `pwd`:/home pactfoundation:python36 sh
23+
```
24+
25+
This will open a container with a prompt. From the /home location in the container you can run
26+
27+
```bash
28+
tox -e py36
29+
```
30+
31+
In all the above if you need to run a different version change py36/python36 where appropriate. Or you can run the convenience script to build:
32+
33+
```bash
34+
docker/build.sh 38
35+
```
36+
37+
where 38 is the python environment version (3.8 in this case)

docker/build.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/sh
2+
set -eo pipefail
3+
4+
if [ $# -ne 1 ]; then
5+
echo "$0: usage: build.sh 27|36|37|38"
6+
exit 1
7+
fi
8+
DOCKER_ENV=$1
9+
echo "Building env ${DOCKER_ENV}"
10+
11+
DOCKER_IMAGE="pactfoundation:python${DOCKER_ENV}"
12+
DOCKER_FILE="docker/py${DOCKER_ENV}.Dockerfile"
13+
14+
docker build -t $DOCKER_IMAGE -f $DOCKER_FILE .

docker/py27.Dockerfile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ WORKDIR /home
44

55
COPY requirements_dev.txt .
66

7-
RUN apk add gcc py-pip python-dev libffi-dev openssl-dev gcc libc-dev make
7+
RUN apk update
8+
RUN apk upgrade
9+
10+
RUN apk add gcc py-pip python-dev libffi-dev openssl-dev gcc libc-dev bash make
811

912
RUN python -m pip install psutil subprocess32
1013
RUN pip install -r requirements_dev.txt
@@ -17,3 +20,5 @@ RUN apk --no-cache add ca-certificates wget && \
1720

1821

1922
RUN ln -sf /usr/glibc-compat/bin/locale /usr/local/bin/locale
23+
24+
CMD tox -e py27

docker/py36.Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM python:3.6.10-alpine3.11
2+
3+
WORKDIR /home
4+
5+
COPY requirements_dev.txt .
6+
7+
RUN apk update
8+
RUN apk upgrade
9+
10+
RUN apk add gcc py-pip python-dev libffi-dev openssl-dev gcc libc-dev bash make
11+
12+
RUN python -m pip install psutil
13+
RUN pip install -r requirements_dev.txt
14+
15+
CMD tox -e py36

docker/py37.Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM python:3.7.7-alpine3.11
2+
3+
WORKDIR /home
4+
5+
COPY requirements_dev.txt .
6+
7+
RUN apk update
8+
RUN apk upgrade
9+
10+
RUN apk add gcc py-pip python-dev libffi-dev openssl-dev gcc libc-dev bash make
11+
12+
RUN python -m pip install psutil
13+
RUN pip install -r requirements_dev.txt
14+
15+
CMD tox -e py37

docker/py38.Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM python:3.8.2-alpine3.11
2+
3+
WORKDIR /home
4+
5+
COPY requirements_dev.txt .
6+
7+
RUN apk update
8+
RUN apk upgrade
9+
10+
RUN apk add gcc py-pip python-dev libffi-dev openssl-dev gcc libc-dev bash make
11+
12+
RUN python -m pip install psutil
13+
RUN pip install -r requirements_dev.txt
14+
15+
CMD tox -e py38

0 commit comments

Comments
 (0)