diff --git a/Dockerfile b/Dockerfile index b7ed7fe..f0aa4ae 100644 --- a/Dockerfile +++ b/Dockerfile @@ -62,6 +62,7 @@ ENV PATH=/app/bin:$PATH ENV PYTHONPATH=/app ENV PYTHONUNBUFFERED=1 ENV HOME=/app +ENV DJANGO_SETTINGS_MODULE=pkmntrade_club.django_project.settings WORKDIR /app @@ -94,11 +95,13 @@ COPY --chown=app:app --chmod=700 /manage.py /app/manage.py ENTRYPOINT ["/entrypoint.sh"] RUN --mount=type=cache,target=${CACHE_DIR} \ - mkdir -p /app/.cursor-server && chown app:app /app /app/.cursor-server + mkdir -p /app/.cursor-server && chmod 755 /app/.cursor-server && chown app:app /app /app/.cursor-server + +RUN --mount=type=cache,target=${CACHE_DIR} \ + mkdir -p /flags && chmod 700 /flags && chown app:app /flags USER app EXPOSE 8000 -CMD ["granian", "--interface", "wsgi", "pkmntrade_club.django_project.wsgi:app", "--host", "0.0.0.0", "--port", "8000", "--workers", "1", "--backpressure", "16", "--workers-kill-timeout", "180", "--access-log"] -#, "--static-path-mount", "./staticfiles" \ No newline at end of file +CMD ["granian", "--interface", "wsgi", "pkmntrade_club.django_project.wsgi:app", "--host", "0.0.0.0", "--port", "8000", "--workers", "1", "--backpressure", "16", "--workers-kill-timeout", "180", "--access-log"] \ No newline at end of file diff --git a/scripts/deploy.sh b/scripts/deploy.sh index 4e97231..5c5393a 100755 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -1,5 +1,10 @@ #!/bin/bash +if [[ -f /flags/.deployed && "$FORCE_DEPLOY" != "true" ]]; then + echo "*** Previously deployed successfully." + exit 0 +fi + echo "*** Running makemigrations --check to make sure migrations are up to date..." django-admin makemigrations --noinput --check 2>&1 || exit 1 @@ -12,4 +17,7 @@ django-admin clear_cache 2>&1 echo "*** Running collectstatic..." django-admin collectstatic -c --no-input 2>&1 +echo "*** Marking as deployed..." +touch /flags/.deployed + echo "*** Deployed successfully!" \ No newline at end of file diff --git a/scripts/entrypoint.sh b/scripts/entrypoint.sh index 972a189..4f0f565 100755 --- a/scripts/entrypoint.sh +++ b/scripts/entrypoint.sh @@ -2,16 +2,18 @@ set -ex if [ "$1" == "" ]; then - echo "Startup command not set. Exiting" - exit; + echo "Startup command not set. Exiting" + exit; fi if [ "$DJANGO_SETTINGS_MODULE" == "" ]; then - echo "Environment variable 'DJANGO_SETTINGS_MODULE' not set. Exiting." - exit; + echo "Environment variable 'DJANGO_SETTINGS_MODULE' not set. Exiting." + exit; else - export DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE + export DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE fi +/deploy.sh + echo "Environment is correct - executing command: '$@'" exec "$@" && exit 0 \ No newline at end of file