Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load admin-index fixtures in docker startup script #1296

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion bin/docker_start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ set -ex
export PGHOST=${DB_HOST:-db}
export PGPORT=${DB_PORT:-5432}

fixtures_dir=${FIXTURES_DIR:-/app/fixtures}
fixtures_dir=${FIXTURES_DIR:-/app/src/open_inwoner/conf/fixtures/autoload}

uwsgi_port=${UWSGI_PORT:-8000}
uwsgi_processes=${UWSGI_PROCESSES:-4}
Expand All @@ -24,6 +24,17 @@ done
>&2 echo "Apply database migrations"
python src/manage.py migrate

# Load JSON fixtures
if [ -d $fixtures_dir ]; then
echo "Loading fixtures from $fixtures_dir"

for fixture in $(ls "$fixtures_dir/"*.json)
do
echo "Loading fixture $fixture"
python src/manage.py loaddata $fixture
done
fi

# Start server
>&2 echo "Starting server"
exec uwsgi \
Expand Down
3 changes: 3 additions & 0 deletions bin/generate_admin_index_fixture.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@
# Run this script from the root of the repository

src/manage.py dumpdata --indent=4 --natural-foreign --natural-primary admin_index.AppGroup admin_index.AppLink > src/open_inwoner/conf/fixtures/django-admin-index.json

# copy admin-index fixture to autoload dir
cp src/open_inwoner/conf/fixtures/django-admin-index.json src/open_inwoner/conf/fixtures/autoload/
10 changes: 5 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ services:
environment:
- POSTGRES_HOST_AUTH_METHOD=trust
volumes:
- ./docker-init-db.sql:/docker-entrypoint-initdb.d/init_db.sql
# - ./docker-init-db.sql:/docker-entrypoint-initdb.d/init_db.sql
- db:/var/lib/postgresql/data
networks:
- openinwoner-dev
- openinwoner-dev

elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:7.9.2
Expand All @@ -21,7 +21,7 @@ services:
- cluster.routing.allocation.disk.threshold_enabled=false
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
networks:
- openinwoner-dev
- openinwoner-dev
volumes:
- es_data:/usr/share/elasticsearch/data
ports:
Expand Down Expand Up @@ -58,7 +58,7 @@ services:
- CACHE_PORTALOCKER=redis:6379/0
- CELERY_BROKER_URL=redis://redis:6379/0
- CELERY_RESULT_BACKEND=redis://redis:6379/0
- CELERY_LOGLEVEL=DEBUG
- CELERY_LOGLEVEL=DEBUG
- ES_HOST=elasticsearch
- DISABLE_2FA=${DISABLE_2FA:-True}
- DEBUG=True
Expand Down Expand Up @@ -107,4 +107,4 @@ volumes:

networks:
openinwoner-dev:
name: openinwoner-dev
name: openinwoner-dev
10 changes: 8 additions & 2 deletions src/open_inwoner/accounts/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
from django.conf import settings
from django.contrib.contenttypes.management import create_contenttypes
from django.core.management import call_command
from django.db.models.signals import post_migrate

# from django.db.models.signals import post_migrate


def update_admin_index(sender=None, **kwargs) -> bool:
Expand Down Expand Up @@ -48,4 +49,9 @@ def ready(self):
return
self._has_run = True

post_migrate.connect(update_admin_index, sender=self)
# FIXME: loading the django-admin-index fixture through the
# post migrate signal is broken; we now load the fixture
# in the docker startup script, so this only affects manual
# installs during development;

# post_migrate.connect(update_admin_index, sender=self)
Loading
Loading