Skip to content
Snippets Groups Projects
Commit 7491218c authored by Tim Neumann's avatar Tim Neumann Committed by Nadja Geisler
Browse files

Add the ability to customize DJANGO settings in container

parent 41a23a16
No related branches found
No related tags found
1 merge request!91Add Dockerfile and dependencies
...@@ -32,6 +32,14 @@ if [ "$DJANGO_SUPERUSER_PASSWORD" != "" ] ;then ...@@ -32,6 +32,14 @@ if [ "$DJANGO_SUPERUSER_PASSWORD" != "" ] ;then
./manage.py createsuperuser --noinput ./manage.py createsuperuser --noinput
fi fi
env | while IFS= read -r line; do
value=${line#*=}
name=${line%%=*}
case $name in EXTRA_DJANGO_SETTING*)
echo -e "$value" > "./AKPlanning/settings/$name.py"
esac
done
./manage.py collectstatic --noinput ./manage.py collectstatic --noinput
./manage.py compilemessages -l de_DE ./manage.py compilemessages -l de_DE
uwsgi --ini .docker/uwsgi.ini uwsgi --ini .docker/uwsgi.ini
...@@ -9,5 +9,7 @@ RUN pip install -r requirements.txt -r .docker/extra_requirements.txt ...@@ -9,5 +9,7 @@ RUN pip install -r requirements.txt -r .docker/extra_requirements.txt
ENV DJANGO_SETTINGS_MODULE=AKPlanning.settings_production ENV DJANGO_SETTINGS_MODULE=AKPlanning.settings_production
RUN mkdir /app/AKPlanning/settings
EXPOSE 3035 EXPOSE 3035
CMD ["sh", "/app/.docker/entrypoint.sh"] CMD ["sh", "/app/.docker/entrypoint.sh"]
...@@ -145,6 +145,7 @@ services: ...@@ -145,6 +145,7 @@ services:
DJANGO_SUPERUSER_USERNAME: admin DJANGO_SUPERUSER_USERNAME: admin
DJANGO_SUPERUSER_EMAIL: admin@example.com DJANGO_SUPERUSER_EMAIL: admin@example.com
DJANGO_SUPERUSER_PASSWORD: supersecret DJANGO_SUPERUSER_PASSWORD: supersecret
EXTRA_DJANGO_SETTING_FOO: DJANGO_FOO = True\nDJANGO_BAR = False
depends_on: depends_on:
- mariadb - mariadb
networks: networks:
...@@ -226,6 +227,12 @@ Using the environment variables `DJANGO_SUPERUSER_{USERNAME,EMAIL,PASSWORD}`. ...@@ -226,6 +227,12 @@ Using the environment variables `DJANGO_SUPERUSER_{USERNAME,EMAIL,PASSWORD}`.
The second way is to run the following command after the container has started: The second way is to run the following command after the container has started:
`docker-compose exec -it akplanning-server ./manage.py createsuperuser` `docker-compose exec -it akplanning-server ./manage.py createsuperuser`
### Extra djnago settings
For simple cases you can pass environment variables starting with `EXTRA_DJANGO_SETTING`.
The content of such variables is written into python files, which are loaded as settings.
For more complex scenarios you can also mount a docker volume to `/app/AKPlanning/settings` and add any number of python files to the volume.
## Updates ## Updates
To update the setup to the current version on the main branch of the repository use the update script ``Utils/update.sh`` or ``Utils/update.sh --prod`` in production. To update the setup to the current version on the main branch of the repository use the update script ``Utils/update.sh`` or ``Utils/update.sh --prod`` in production.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment