Skip to content
This repository was archived by the owner on Aug 15, 2019. It is now read-only.

Commit 4c77a4e

Browse files
committed
Refactor the Dockerfile to build from the Django source directory. Closes #5
1 parent 865f6d4 commit 4c77a4e

File tree

4 files changed

+72
-54
lines changed

4 files changed

+72
-54
lines changed

Dockerfile

+7-3
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,14 @@ RUN echo "test ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/test && \
2020
chmod 0440 /etc/sudoers.d/test
2121
RUN pip install --upgrade pip
2222

23-
RUN mkdir /tests && chown -R test:test /tests
24-
COPY --chown=test:test entrypoint.sh /entrypoint.sh
23+
COPY --chown=test:test tests/requirements/ /requirements/
24+
RUN pip install -r /requirements/py3.txt
25+
ARG EXTRA_REQUIREMENTS
26+
RUN test -z ${EXTRA_REQUIREMENTS} || pip install -r /requirements/${EXTRA_REQUIREMENTS}
2527

28+
RUN mkdir /tests && chown -R test:test /tests
2629
USER test:test
2730
ENV PYTHONPATH "${PYTHONPATH}:/tests/django"
28-
ENTRYPOINT /entrypoint.sh
2931
WORKDIR /tests
32+
33+
ENTRYPOINT /entrypoint.sh

docker-compose.yml

+53-24
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@ version: "2.3"
33

44
x-base: &base
55
build:
6-
context: .
6+
context: ${DJANGO_PATH}
7+
dockerfile: ${PWD}/Dockerfile
78
args:
89
- PYTHON_VERSION=${PYTHON_VERSION}
910
volumes:
1011
- ${DJANGO_PATH}:/tests/django/
1112
- ./settings:/tests/django/tests/settings
1213
- ./extra-requirements:/tests/django/tests/requirements/extra/
13-
- ./entrypoint.sh:/entrypoint.sh
14-
- ${PIP_CACHE_VOLUME}:/root/.cache/pip/
14+
- ./oracle_entrypoint.sh:/oracle_entrypoint.sh
1515
# Using yaml merging here overwrites the arrays. Simpler to just mount this in every service.
1616
- ./oracle:/oracle
17-
entrypoint: /entrypoint.sh python tests/runtests.py
17+
entrypoint: python django/tests/runtests.py
1818

1919
services:
2020
sqlite:
@@ -34,9 +34,14 @@ services:
3434

3535
postgres:
3636
<<: *base
37+
build:
38+
context: ${DJANGO_PATH}
39+
dockerfile: ${PWD}/Dockerfile
40+
args:
41+
- PYTHON_VERSION=${PYTHON_VERSION}
42+
- EXTRA_REQUIREMENTS=postgres.txt
3743
environment:
3844
- DJANGO_SETTINGS_MODULE=settings.test_postgres
39-
- EXTRA_REQUIREMENTS=postgres.txt
4045
depends_on:
4146
postgres-db:
4247
condition: service_healthy
@@ -56,6 +61,12 @@ services:
5661

5762
postgres-gis:
5863
<<: *base
64+
build:
65+
context: ${DJANGO_PATH}
66+
dockerfile: ${PWD}/Dockerfile
67+
args:
68+
- PYTHON_VERSION=${PYTHON_VERSION}
69+
- EXTRA_REQUIREMENTS=postgres.txt
5970
environment:
6071
- DJANGO_SETTINGS_MODULE=settings.test_postgres_gis
6172
- EXTRA_REQUIREMENTS=postgres.txt
@@ -75,9 +86,14 @@ services:
7586

7687
mysql:
7788
<<: *base
89+
build:
90+
context: ${DJANGO_PATH}
91+
dockerfile: ${PWD}/Dockerfile
92+
args:
93+
- PYTHON_VERSION=${PYTHON_VERSION}
94+
- EXTRA_REQUIREMENTS=mysql.txt
7895
environment:
7996
- DJANGO_SETTINGS_MODULE=settings.test_mysql
80-
- EXTRA_REQUIREMENTS=mysql.txt
8197
depends_on:
8298
mysql-db:
8399
condition: service_healthy
@@ -98,9 +114,14 @@ services:
98114

99115
mysql-gis:
100116
<<: *base
117+
build:
118+
context: ${DJANGO_PATH}
119+
dockerfile: ${PWD}/Dockerfile
120+
args:
121+
- PYTHON_VERSION=${PYTHON_VERSION}
122+
- EXTRA_REQUIREMENTS=mysql.txt
101123
environment:
102124
- DJANGO_SETTINGS_MODULE=settings.test_mysql_gis
103-
- EXTRA_REQUIREMENTS=mysql.txt
104125
depends_on:
105126
mysql-gis-db:
106127
condition: service_healthy
@@ -111,9 +132,14 @@ services:
111132

112133
mariadb:
113134
<<: *base
135+
build:
136+
context: ${DJANGO_PATH}
137+
dockerfile: ${PWD}/Dockerfile
138+
args:
139+
- PYTHON_VERSION=${PYTHON_VERSION}
140+
- EXTRA_REQUIREMENTS=mysql.txt
114141
environment:
115142
- DJANGO_SETTINGS_MODULE=settings.test_mariadb
116-
- EXTRA_REQUIREMENTS=mysql.txt
117143
depends_on:
118144
mariadb-db:
119145
condition: service_healthy
@@ -133,10 +159,15 @@ services:
133159

134160
oracle:
135161
<<: *base
162+
build:
163+
context: ${DJANGO_PATH}
164+
dockerfile: ${PWD}/Dockerfile
165+
args:
166+
- PYTHON_VERSION=${PYTHON_VERSION}
167+
- EXTRA_REQUIREMENTS=oracle.txt
136168
environment:
137169
- DJANGO_SETTINGS_MODULE=settings.test_oracle
138-
- EXTRA_REQUIREMENTS=oracle.txt
139-
- IS_ORACLE=1
170+
entrypoint: /oracle_entrypoint.sh python tests/runtests.py
140171
depends_on:
141172
oracle-db:
142173
condition: service_healthy
@@ -170,22 +201,20 @@ services:
170201
interval: 30s
171202
retries: 10
172203

173-
docs:
174-
<<: *base
175-
environment:
176-
- EXTRA_REQUIREMENTS=extra/docs.txt
177-
entrypoint: /entrypoint.sh
178-
command: bash -c "cd docs && make spelling"
179-
user: root
180-
181-
flake8:
182-
<<: *base
183-
environment:
184-
- EXTRA_REQUIREMENTS=extra/linting.txt
185-
entrypoint: /entrypoint.sh flake8
204+
# docs:
205+
# <<: *base
206+
# environment:
207+
# - EXTRA_REQUIREMENTS=extra/docs.txt
208+
# command: bash -c "cd docs && make spelling"
209+
# user: root
210+
#
211+
# flake8:
212+
# <<: *base
213+
# environment:
214+
# - EXTRA_REQUIREMENTS=extra/linting.txt
215+
# entrypoint: /entrypoint.sh flake8
186216

187217
volumes:
188-
pip-cache:
189218
oracle:
190219
mysql:
191220
mysql-gis:

entrypoint.sh

-27
This file was deleted.

oracle_entrypoint.sh

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
IFS=$'\n\t'
5+
6+
if compgen -G "/oracle/*.zip" > /dev/null; then
7+
sudo mkdir -p /opt/oracle
8+
sudo unzip /oracle/*.zip -d /opt/oracle
9+
sudo bash -c "echo /opt/oracle/instantclient* > /etc/ld.so.conf.d/oracle-instantclient.conf"
10+
sudo ldconfig
11+
fi
12+
exec $@

0 commit comments

Comments
 (0)