docker: add test setup
parent
75e989a056
commit
4e3eb7dd5e
@ -0,0 +1,29 @@
|
||||
FROM python:3.9-bullseye
|
||||
|
||||
# install additional dependencies
|
||||
RUN apt-get update && apt-get install -y gettext texlive texlive-fonts-extra
|
||||
|
||||
# create user
|
||||
RUN groupadd -g 501 app && useradd -g 501 -u 501 -m -d /app app
|
||||
|
||||
# create static directory and set permissions, when doing this before mounting a named volume
|
||||
# in docker-compose.yaml, the permissions are inherited during the mount.
|
||||
RUN mkdir -p /var/www/jdav_web/static && chown -R app:app /var/www/jdav_web/static
|
||||
|
||||
# create static directory and set permissions, when doing this before mounting a named volume
|
||||
# in docker-compose.yaml, the permissions are inherited during the mount.
|
||||
RUN mkdir -p /tmp/uwsgi && chown -R app:app /tmp/uwsgi
|
||||
|
||||
WORKDIR /app
|
||||
USER app
|
||||
|
||||
# add .local/bin to PATH
|
||||
ENV PATH="/app/.local/bin:$PATH"
|
||||
|
||||
# install requirements
|
||||
COPY --chown=app:app ./requirements.txt /app/requirements.txt
|
||||
# we install uwsgi here to check if packages dependencies are resolved, but we don't actually
|
||||
# need uwsgi in test
|
||||
RUN pip install coverage uwsgi -r requirements.txt
|
||||
|
||||
COPY --chown=app:app . /app
|
||||
@ -0,0 +1,30 @@
|
||||
version: "3.9"
|
||||
|
||||
services:
|
||||
master:
|
||||
image: kompass:test
|
||||
build:
|
||||
context: ./../../
|
||||
dockerfile: docker/test/Dockerfile
|
||||
env_file: docker.env
|
||||
depends_on:
|
||||
- redis
|
||||
- cache
|
||||
- db
|
||||
entrypoint: /app/docker/test/entrypoint-master.sh
|
||||
|
||||
cache:
|
||||
restart: always
|
||||
image: memcached:alpine
|
||||
|
||||
redis:
|
||||
restart: always
|
||||
image: redis:6-alpine
|
||||
|
||||
db:
|
||||
restart: always
|
||||
image: mariadb
|
||||
volumes:
|
||||
- ./db:/var/lib/mysql
|
||||
- ./provision/mysql/init:/docker-entrypoint-initdb.d
|
||||
env_file: docker.env
|
||||
@ -0,0 +1,28 @@
|
||||
DJANGO_ALLOWED_HOST='*'
|
||||
DJANGO_BASE_URL='localhost:8000'
|
||||
DJANGO_PROTOCOL='http'
|
||||
|
||||
EMAIL_HOST='localhost'
|
||||
EMAIL_HOST_USER='test'
|
||||
EMAIL_HOST_PASSWORD='password'
|
||||
EMAIL_SENDING_ADDRESS='test@localhost'
|
||||
|
||||
DJANGO_DEPLOY=1
|
||||
DJANGO_DEBUG=1
|
||||
|
||||
DJANGO_DATABASE_NAME='kompass'
|
||||
DJANGO_DATABASE_USER='kompass'
|
||||
DJANGO_DATABASE_PASSWORD='password'
|
||||
DJANGO_DATABASE_HOST='db'
|
||||
DJANGO_DATABASE_PORT=3306
|
||||
|
||||
MYSQL_ROOT_PASSWORD='secretpassword'
|
||||
MYSQL_PASSWORD='password'
|
||||
MYSQL_USER='kompass'
|
||||
MYSQL_DATABASE='kompass'
|
||||
|
||||
DJANGO_SETTINGS_MODULE='jdav_web.settings'
|
||||
DJANGO_STATIC_ROOT='/var/www/jdav_web/assets'
|
||||
|
||||
MEMCACHED_URL='cache:11211'
|
||||
BROKER_URL='redis://redis:6379/0'
|
||||
@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -o errexit
|
||||
|
||||
mysql_ready() {
|
||||
cd /app/jdav_web
|
||||
python << END
|
||||
import sys
|
||||
|
||||
from django.db import connections
|
||||
from django.db.utils import OperationalError
|
||||
|
||||
db_conn = connections['default']
|
||||
|
||||
try:
|
||||
c = db_conn.cursor()
|
||||
except OperationalError:
|
||||
sys.exit(-1)
|
||||
else:
|
||||
sys.exit(0)
|
||||
|
||||
END
|
||||
}
|
||||
|
||||
until mysql_ready; do
|
||||
>&2 echo 'Waiting for MySQL to become available...'
|
||||
sleep 1
|
||||
done
|
||||
>&2 echo 'MySQL is available'
|
||||
|
||||
cd /app
|
||||
|
||||
if ! [ -f /tmp/completed_initial_run ]; then
|
||||
echo 'Initialising kompass master container'
|
||||
|
||||
python jdav_web/manage.py compilemessages --locale de
|
||||
fi
|
||||
|
||||
cd jdav_web
|
||||
|
||||
coverage run manage.py test startpage finance members -v 2
|
||||
@ -0,0 +1 @@
|
||||
GRANT ALL PRIVILEGES ON test_kompass.* TO 'kompass'@'%';
|
||||
Loading…
Reference in New Issue