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

Commit

Permalink
Refactor the Dockerfile to build from the Django source directory. #5
Browse files Browse the repository at this point in the history
  • Loading branch information
orf committed Oct 21, 2018
1 parent 865f6d4 commit 0461a20
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 40 deletions.
10 changes: 7 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,14 @@ RUN echo "test ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/test && \
chmod 0440 /etc/sudoers.d/test
RUN pip install --upgrade pip

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

RUN mkdir /tests && chown -R test:test /tests
USER test:test
ENV PYTHONPATH "${PYTHONPATH}:/tests/django"
ENTRYPOINT /entrypoint.sh
WORKDIR /tests

ENTRYPOINT /entrypoint.sh
39 changes: 29 additions & 10 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ version: "2.3"

x-base: &base
build:
context: .
context: ${DJANGO_PATH}
dockerfile: ${PWD}/Dockerfile
args:
- PYTHON_VERSION=${PYTHON_VERSION}
volumes:
- ${DJANGO_PATH}:/tests/django/
- ./settings:/tests/django/tests/settings
- ./extra-requirements:/tests/django/tests/requirements/extra/
- ./entrypoint.sh:/entrypoint.sh
- ${PIP_CACHE_VOLUME}:/root/.cache/pip/
- ./oracle_entrypoint.sh:/oracle_entrypoint.sh
# Using yaml merging here overwrites the arrays. Simpler to just mount this in every service.
- ./oracle:/oracle
entrypoint: /entrypoint.sh python tests/runtests.py
entrypoint: python django/tests/runtests.py

services:
sqlite:
Expand All @@ -34,9 +34,14 @@ services:

postgres:
<<: *base
build:
context: ${DJANGO_PATH}
dockerfile: ${PWD}/Dockerfile
args:
- PYTHON_VERSION=${PYTHON_VERSION}
- EXTRA_REQUIREMENTS=postgres.txt
environment:
- DJANGO_SETTINGS_MODULE=settings.test_postgres
- EXTRA_REQUIREMENTS=postgres.txt
depends_on:
postgres-db:
condition: service_healthy
Expand Down Expand Up @@ -75,9 +80,14 @@ services:

mysql:
<<: *base
build:
context: ${DJANGO_PATH}
dockerfile: ${PWD}/Dockerfile
args:
- PYTHON_VERSION=${PYTHON_VERSION}
- EXTRA_REQUIREMENTS=mysql.txt
environment:
- DJANGO_SETTINGS_MODULE=settings.test_mysql
- EXTRA_REQUIREMENTS=mysql.txt
depends_on:
mysql-db:
condition: service_healthy
Expand Down Expand Up @@ -111,9 +121,14 @@ services:

mariadb:
<<: *base
build:
context: ${DJANGO_PATH}
dockerfile: ${PWD}/Dockerfile
args:
- PYTHON_VERSION=${PYTHON_VERSION}
- EXTRA_REQUIREMENTS=mysql.txt
environment:
- DJANGO_SETTINGS_MODULE=settings.test_mariadb
- EXTRA_REQUIREMENTS=mysql.txt
depends_on:
mariadb-db:
condition: service_healthy
Expand All @@ -133,10 +148,15 @@ services:

oracle:
<<: *base
build:
context: ${DJANGO_PATH}
dockerfile: ${PWD}/Dockerfile
args:
- PYTHON_VERSION=${PYTHON_VERSION}
- EXTRA_REQUIREMENTS=oracle.txt
environment:
- DJANGO_SETTINGS_MODULE=settings.test_oracle
- EXTRA_REQUIREMENTS=oracle.txt
- IS_ORACLE=1
entrypoint: /oracle_entrypoint.sh python tests/runtests.py
depends_on:
oracle-db:
condition: service_healthy
Expand Down Expand Up @@ -185,7 +205,6 @@ services:
entrypoint: /entrypoint.sh flake8

volumes:
pip-cache:
oracle:
mysql:
mysql-gis:
Expand Down
27 changes: 0 additions & 27 deletions entrypoint.sh

This file was deleted.

12 changes: 12 additions & 0 deletions oracle_entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

set -e
IFS=$'\n\t'

if compgen -G "/oracle/*.zip" > /dev/null; then
sudo mkdir -p /opt/oracle
sudo unzip /oracle/*.zip -d /opt/oracle
sudo bash -c "echo /opt/oracle/instantclient* > /etc/ld.so.conf.d/oracle-instantclient.conf"
sudo ldconfig
fi
exec $@

0 comments on commit 0461a20

Please sign in to comment.