Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #30010 -- Add docker-compose support
- Loading branch information
Showing
15 changed files
with
408 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.git/ | ||
__pycache__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,3 +42,7 @@ indent_style = tab | |
|
||
[docs/**.txt] | ||
max_line_length = 79 | ||
|
||
[*.yml] | ||
indent_size = 2 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
PYTHON_VERSION=3.5 | ||
POSTGRES_VERSION=9.6 | ||
POSTGIS_VERSION=2.5 | ||
MYSQL_VERSION=8 | ||
MARIADB_VERSION=10.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
version: "2.3" | ||
|
||
x-base: &base | ||
image: django-ci:${PYTHON_VERSION} | ||
build: | ||
context: . | ||
dockerfile: docker/Dockerfile | ||
args: | ||
- PYTHON_VERSION=${PYTHON_VERSION} | ||
volumes: | ||
- .:/django/ | ||
entrypoint: bash -c "wait-for-it.sh -s -t 20 $${WAIT_FOR} -- python tests/runtests.py $$@" -- | ||
|
||
x-postgres-base: &postgres-base | ||
environment: | ||
- POSTGRES_USER=django | ||
- POSTGRES_PASSWORD=django | ||
- POSTGRES_DB=django | ||
# Set a few options to speed up postgresql tests. | ||
command: -c fsync=off -c synchronous_commit=off -c full_page_writes=off | ||
tmpfs: | ||
- /var/lib/postgresql | ||
|
||
services: | ||
sqlite: | ||
<<: *base | ||
environment: | ||
- DJANGO_SETTINGS_MODULE=docker_settings.test_sqlite | ||
entrypoint: python tests/runtests.py | ||
depends_on: | ||
- memcached | ||
- memcached2 | ||
|
||
sqlite-gis: | ||
<<: *base | ||
entrypoint: python tests/runtests.py | ||
environment: | ||
- DJANGO_SETTINGS_MODULE=docker_settings.test_sqlite_gis | ||
|
||
postgres: | ||
<<: *base | ||
environment: | ||
- DJANGO_SETTINGS_MODULE=docker_settings.test_postgres | ||
- WAIT_FOR=postgres-db:5432 | ||
depends_on: | ||
- postgres-db | ||
- memcached | ||
- memcached2 | ||
postgres-db: | ||
<<: *postgres-base | ||
image: postgres:${POSTGRES_VERSION}-alpine | ||
|
||
postgres-gis: | ||
<<: *base | ||
environment: | ||
- DJANGO_SETTINGS_MODULE=docker_settings.test_postgres_gis | ||
- WAIT_FOR=postgres-gis-db:5432 | ||
depends_on: | ||
- postgres-gis-db | ||
postgres-gis-db: | ||
<<: *postgres-base | ||
build: | ||
dockerfile: docker/Dockerfile-postgis | ||
context: . | ||
args: | ||
- POSTGRES_VERSION=${POSTGRES_VERSION} | ||
- POSTGIS_VERSION=${POSTGIS_VERSION} | ||
|
||
mysql: | ||
<<: *base | ||
environment: | ||
- DJANGO_SETTINGS_MODULE=docker_settings.test_mysql | ||
- WAIT_FOR=mysql-db:3306 | ||
depends_on: | ||
- mysql-db | ||
- memcached | ||
- memcached2 | ||
mysql-db: &mysql_base | ||
image: mysql:${MYSQL_VERSION} | ||
entrypoint: ['/entrypoint.sh', '--default-authentication-plugin=mysql_native_password'] | ||
tmpfs: | ||
- /var/lib/mysql | ||
environment: | ||
- MYSQL_USER=django | ||
- MYSQL_PASSWORD=django | ||
- MYSQL_DATABASE=django | ||
- MYSQL_ALLOW_EMPTY_PASSWORD=1 | ||
|
||
mysql-gis: | ||
<<: *base | ||
environment: | ||
- DJANGO_SETTINGS_MODULE=docker_settings.test_mysql_gis | ||
- WAIT_FOR=mysql-gis-db:3306 | ||
depends_on: | ||
- mysql-gis-db | ||
mysql-gis-db: | ||
<<: *mysql_base | ||
volumes: | ||
- /var/lib/mysql | ||
|
||
mariadb: | ||
<<: *base | ||
environment: | ||
- DJANGO_SETTINGS_MODULE=docker_settings.test_mariadb | ||
- WAIT_FOR=mariadb-db:3306 | ||
depends_on: | ||
- mariadb-db | ||
- memcached | ||
- memcached2 | ||
mariadb-db: | ||
image: mariadb:${MARIADB_VERSION} | ||
tmpfs: | ||
- /var/lib/mysql | ||
environment: | ||
- MYSQL_USER=django | ||
- MYSQL_PASSWORD=django | ||
- MYSQL_DATABASE=django | ||
- MYSQL_ALLOW_EMPTY_PASSWORD=1 | ||
|
||
memcached: &memcached | ||
image: memcached:alpine | ||
|
||
memcached2: | ||
<<: *memcached | ||
|
||
flake8: | ||
<<: *base | ||
entrypoint: flake8 | ||
|
||
# Browser tests | ||
chrome: | ||
<<: *base | ||
command: --selenium=chrome --selenium-hub=http://chrome-browser:4444/wd/hub | ||
environment: | ||
- WAIT_FOR=chrome-browser:4444 | ||
depends_on: | ||
- chrome-browser | ||
chrome-browser: | ||
image: selenium/standalone-chrome | ||
volumes: | ||
- /dev/shm:/dev/shm | ||
|
||
# Firefox tests fail on master | ||
firefox: | ||
<<: *base | ||
command: --selenium=firefox --selenium-hub=http://firefox-browser:4444/wd/hub | ||
environment: | ||
- WAIT_FOR=firefox-browser:4444 | ||
depends_on: | ||
- firefox-browser | ||
firefox-browser: | ||
image: selenium/standalone-firefox | ||
volumes: | ||
- /dev/shm:/dev/shm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
ARG PYTHON_VERSION | ||
FROM python:${PYTHON_VERSION}-slim | ||
|
||
RUN apt-get update \ | ||
&& apt-get install -y --no-install-recommends \ | ||
libmemcached-dev \ | ||
build-essential \ | ||
libsqlite3-mod-spatialite binutils libproj-dev gdal-bin libgdal20 libgeoip1 \ | ||
default-libmysqlclient-dev default-mysql-client \ | ||
unzip libaio1 \ | ||
gettext \ | ||
wget git \ | ||
&& apt-get clean | ||
|
||
RUN groupadd -r test && useradd --no-log-init -r -g test test | ||
|
||
RUN mkdir /geolite2/ \ | ||
&& cd /geolite2/ \ | ||
&& wget -q http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.tar.gz \ | ||
http://geolite.maxmind.com/download/geoip/database/GeoLite2-Country.tar.gz \ | ||
&& (cat *.tar.gz | tar zxvf - --wildcards "*.mmdb" --strip-components=1 -i) \ | ||
&& rm *.tar.gz \ | ||
&& cd / | ||
|
||
RUN wget -q https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh -O /bin/wait-for-it.sh \ | ||
&& chmod a+x /bin/wait-for-it.sh | ||
|
||
ENV PIP_NO_CACHE_DIR=off | ||
ENV PYTHONDONTWRITEBYTECODE=1 | ||
RUN pip install --upgrade pip | ||
|
||
COPY ./tests/requirements /tmp/requirements | ||
RUN for f in /tmp/requirements/*.txt; do pip install -r $f; done && \ | ||
pip install flake8 flake8-isort selenium | ||
|
||
ENV PYTHONPATH "${PYTHONPATH}:/django/:/django/docker/" | ||
USER test:test | ||
WORKDIR /django | ||
VOLUME /django | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
ARG POSTGRES_VERSION | ||
FROM postgres:${POSTGRES_VERSION} | ||
|
||
RUN echo 'CREATE EXTENSION IF NOT EXISTS "postgis";' > /docker-entrypoint-initdb.d/postgis.sql | ||
|
||
ARG POSTGIS_VERSION | ||
ARG POSTGRES_VERSION | ||
RUN apt-get update \ | ||
&& apt-get install -y postgresql-${POSTGRES_VERSION}-postgis-${POSTGIS_VERSION} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from .test_sqlite import * # NOQA | ||
|
||
DATABASES = { | ||
'default': { | ||
'ENGINE': 'django.db.backends.mysql', | ||
'USER': 'root', | ||
'PASSWORD': '', | ||
'NAME': 'django', | ||
'HOST': 'mariadb-db', | ||
'TEST': { | ||
'CHARSET': 'utf8', | ||
}, | ||
}, | ||
'other': { | ||
'ENGINE': 'django.db.backends.mysql', | ||
'USER': 'root', | ||
'PASSWORD': '', | ||
'NAME': 'django2', | ||
'HOST': 'mariadb-db', | ||
'TEST': { | ||
'CHARSET': 'utf8', | ||
}, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from .test_sqlite import * # NOQA | ||
|
||
DATABASES = { | ||
'default': { | ||
'ENGINE': 'django.db.backends.mysql', | ||
'USER': 'root', | ||
'PASSWORD': '', | ||
'NAME': 'django', | ||
'HOST': 'mysql-db', | ||
'TEST': { | ||
'CHARSET': 'utf8', | ||
}, | ||
}, | ||
'other': { | ||
'ENGINE': 'django.db.backends.mysql', | ||
'USER': 'root', | ||
'PASSWORD': '', | ||
'NAME': 'django2', | ||
'HOST': 'mysql-db', | ||
'TEST': { | ||
'CHARSET': 'utf8', | ||
}, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from .test_sqlite import * # NOQA | ||
|
||
DATABASES = { | ||
'default': { | ||
'ENGINE': 'django.contrib.gis.db.backends.mysql', | ||
'USER': 'root', | ||
'PASSWORD': '', | ||
'NAME': 'django', | ||
'HOST': 'mysql-gis-db', | ||
'TEST': { | ||
'CHARSET': 'utf8', | ||
}, | ||
}, | ||
'other': { | ||
'ENGINE': 'django.contrib.gis.db.backends.mysql', | ||
'USER': 'root', | ||
'PASSWORD': '', | ||
'NAME': 'django2', | ||
'HOST': 'mysql-gis-db', | ||
'TEST': { | ||
'CHARSET': 'utf8', | ||
}, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from .test_sqlite import * # NOQA | ||
|
||
DATABASES = { | ||
'default': { | ||
'ENGINE': 'django.db.backends.postgresql', | ||
'USER': 'django', | ||
'PASSWORD': 'django', | ||
'NAME': 'django', | ||
'HOST': 'postgres-db' | ||
}, | ||
'other': { | ||
'ENGINE': 'django.db.backends.postgresql', | ||
'USER': 'django', | ||
'NAME': 'django2', | ||
'PASSWORD': 'django', | ||
'HOST': 'postgres-db' | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from .test_sqlite import * # NOQA | ||
|
||
DATABASES = { | ||
'default': { | ||
'ENGINE': 'django.contrib.gis.db.backends.postgis', | ||
'USER': 'django', | ||
'PASSWORD': 'django', | ||
'NAME': 'django', | ||
'HOST': 'postgres-gis-db' | ||
}, | ||
'other': { | ||
'ENGINE': 'django.contrib.gis.db.backends.postgis', | ||
'USER': 'django', | ||
'NAME': 'django2', | ||
'PASSWORD': 'django', | ||
'HOST': 'postgres-gis-db' | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
DATABASES = { | ||
'default': { | ||
'ENGINE': 'django.db.backends.sqlite3', | ||
}, | ||
'other': { | ||
'ENGINE': 'django.db.backends.sqlite3', | ||
} | ||
} | ||
|
||
SECRET_KEY = "django_tests_secret_key" | ||
|
||
# Use a fast hasher to speed up tests. | ||
PASSWORD_HASHERS = [ | ||
'django.contrib.auth.hashers.MD5PasswordHasher', | ||
] | ||
|
||
|
||
CACHES = { | ||
'default': { | ||
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', | ||
}, | ||
'memcached': { | ||
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache', | ||
'LOCATION': 'memcached:11211', | ||
'KEY_PREFIX': '1:' | ||
}, | ||
'memcached_2': { | ||
'BACKEND': 'django.core.cache.backends.memcached.PyLibMCCache', | ||
'LOCATION': 'memcached2:11211', | ||
'KEY_PREFIX': '2:' | ||
} | ||
} | ||
|
||
GEOIP_PATH = '/geolite2/' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from .test_sqlite import * # NOQA | ||
|
||
DATABASES = { | ||
'default': { | ||
'ENGINE': 'django.contrib.gis.db.backends.spatialite', | ||
}, | ||
'other': { | ||
'ENGINE': 'django.contrib.gis.db.backends.spatialite', | ||
} | ||
} |
Oops, something went wrong.