-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #307 from dachrisch/master
live db and deploy workflow updates
- Loading branch information
Showing
11 changed files
with
76 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,47 @@ | ||
FROM python:3.11-slim AS app | ||
ENV PYTHONDONTWRITEBYTECODE=1 | ||
ENV PYTHONUNBUFFERED=1 | ||
ARG APP_USER="django" | ||
ARG APP_DIR="/app" | ||
# install curl for healthcheck | ||
FROM python:3.11-slim AS app-builder | ||
|
||
RUN apt -y update | ||
RUN apt -y install curl | ||
RUN apt -y install pkg-config | ||
RUN apt -y install python3-dev | ||
RUN apt -y install build-essential | ||
RUN apt -y install default-libmysqlclient-dev | ||
# add user | ||
RUN adduser --disabled-password --home ${APP_DIR} ${APP_USER} | ||
RUN chown ${APP_USER}:${APP_USER} -R ${APP_DIR} | ||
RUN apt -y install default-libmysqlclient-dev # to build the mysql client | ||
RUN apt -y install git # for development dependency in requirements.txt | ||
|
||
COPY ../requirements.txt . | ||
|
||
WORKDIR ${APP_DIR} | ||
COPY --chown=${APP_USER} ../requirements.txt ${APP_DIR} | ||
RUN pip install --upgrade pip | ||
RUN pip install -r requirements.txt | ||
RUN pip install gunicorn | ||
RUN pip install django-debug-toolbar | ||
|
||
RUN apt -y remove pkg-config | ||
RUN apt -y install python3-dev | ||
RUN apt -y install build-essential | ||
RUN apt -y install default-libmysqlclient-dev | ||
FROM python:3.11-slim AS app | ||
|
||
ENV PYTHONDONTWRITEBYTECODE=1 | ||
ENV PYTHONUNBUFFERED=1 | ||
ARG APP_USER="django" | ||
ARG APP_DIR="/app" | ||
|
||
RUN apt -y update | ||
RUN apt -y install curl # install curl for healthcheck | ||
RUN apt -y install jq # install jq for healthcheck | ||
RUN apt -y install default-libmysqlclient-dev # to run the mysql client | ||
RUN pip install gunicorn | ||
|
||
# add user | ||
RUN adduser --disabled-password --home ${APP_DIR} ${APP_USER} | ||
RUN chown ${APP_USER}:${APP_USER} -R ${APP_DIR} | ||
|
||
USER ${APP_USER} | ||
COPY --chown=${APP_USER} ../ ${APP_DIR} | ||
RUN rm -rf .git/ | ||
|
||
COPY --chown=${APP_USER} --from=app-builder /usr/local/lib/python3.11/site-packages/ /usr/local/lib/python3.11/site-packages/ | ||
|
||
COPY --chown=${APP_USER} ../container/entrypoint.sh /app/entrypoint.sh | ||
|
||
RUN chmod 740 /app/entrypoint.sh | ||
|
||
WORKDIR ${APP_DIR} | ||
|
||
EXPOSE 8000 | ||
|
||
ENTRYPOINT ["/app/entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
#!/bin/sh | ||
|
||
python manage.py makemigrations --no-input | ||
python manage.py migrate --no-input | ||
# Run migrations only if RUN_MIGRATIONS is set to "true" | ||
if [ "$RUN_MIGRATIONS" = "true" ]; then | ||
echo "Running database migrations..." | ||
python manage.py makemigrations --no-input | ||
python manage.py migrate --no-input | ||
fi | ||
|
||
exec "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters