Skip to content

Commit

Permalink
control migration and collectstatic vie env variables
Browse files Browse the repository at this point in the history
  • Loading branch information
nicokant committed Nov 15, 2023
1 parent b0f9d15 commit f27cc98
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ COPY --from=production /app .
COPY --from=translation /app/locale locale
COPY --from=source /app .
COPY entrypoint.sh .
ENV DJANGO_ENV=production
ENV DJANGO_COLLECTSTATIC=1
ENTRYPOINT ["./entrypoint.sh"]

FROM pdm as dev
Expand All @@ -58,5 +58,5 @@ RUN --mount=type=cache,target=/root/.cache/pdm \
COPY --from=django /app/locale locale
COPY --from=django /app/manage.py .
COPY --from=django /app/entrypoint.sh .
ENV DJANGO_ENV=dev
ENV DJANGO_MIGRATE=1
ENTRYPOINT ["./entrypoint.sh"]
9 changes: 8 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,17 @@ else
python manage.py wait_for_http "$WAIT_FOR_HTTP"
fi

if [ "$DJANGO_ENV" == "dev" ]
if [[ -z "${DJANGO_MIGRATE}" ]]
then
echo "Skip migration and setup"
else
python manage.py migrate
python manage.py setup
fi

if [[ -z "${DJANGO_COLLECTSTATIC}" ]]
then
echo "Skip collectstatic"
else
python manage.py collectstatic --noinput
fi
Expand Down

0 comments on commit f27cc98

Please sign in to comment.