Skip to content

Commit

Permalink
Merge pull request #57 from maykinmedia/issue/55-load-fixtures-automa…
Browse files Browse the repository at this point in the history
…tically

🐳 [#55] Load fixtures automatically in docker
  • Loading branch information
stevenbal authored Mar 4, 2025
2 parents 0b3dff7 + 64a0948 commit d95fb6b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ COPY ./bin/docker_start.sh /start.sh
# COPY ./bin/celery_beat.sh /celery_beat.sh
# COPY ./bin/celery_flower.sh /celery_flower.sh
COPY ./bin/wait_for_db.sh /wait_for_db.sh
COPY ./bin/load_fixtures.sh /load_fixtures.sh
COPY ./bin/setup_configuration.sh /setup_configuration.sh
RUN mkdir /app/bin /app/log /app/media

Expand Down
2 changes: 2 additions & 0 deletions bin/docker_start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ ${SCRIPTPATH}/wait_for_db.sh
>&2 echo "Apply database migrations"
python src/manage.py migrate

${SCRIPTPATH}/load_fixtures.sh

# Start server
>&2 echo "Starting server"
exec uwsgi \
Expand Down
16 changes: 16 additions & 0 deletions bin/load_fixtures.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

set -e

fixtures_dir=${FIXTURES_DIR:-/app/fixtures}

# Load any JSON fixtures present
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

0 comments on commit d95fb6b

Please sign in to comment.