-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
2,842 additions
and
135 deletions.
There are no files selected for viewing
File renamed without changes.
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,29 +1,31 @@ | ||
FROM python:3.8 | ||
FROM python:3.8-slim-buster | ||
|
||
ENV PYTHONUNBUFFERED=1 | ||
ENV PYTHONDONTWRITEBYTECODE=1 | ||
ENV POETRY_VIRTUALENVS_CREATE=0 | ||
ENV USER=app_user | ||
|
||
RUN adduser --uid 1000 --gecos --quiet --disabled-password app_user | ||
RUN adduser --uid 1000 --gecos --quiet --disabled-password $USER | ||
|
||
RUN mkdir -p /usr/src/app \ | ||
&& chown app_user.app_user /usr/src/app | ||
&& chown $USER.$USER /usr/src/app | ||
WORKDIR /usr/src/app | ||
|
||
COPY --chown=app_user requirements.txt ./ | ||
COPY --chown=$USER pyproject.toml poetry.lock ./ | ||
|
||
ARG PIP_ARGS= | ||
ARG POETRY_ARGS= | ||
RUN set -eux \ | ||
&& apt update \ | ||
&& apt upgrade -y \ | ||
&& apt install -y curl\ | ||
&& pip3 install -r requirements.txt $PIP_ARGS \ | ||
&& pip3 install poetry \ | ||
&& poetry install --no-root --no-interaction $POETRY_ARGS \ | ||
&& apt autoremove -y \ | ||
&& rm -rf /root/.cache/pip /var/cache/apt | ||
&& rm -rf /root/.cache/pip /root/.cache/pypoetry /var/cache/apt | ||
|
||
COPY --chown=app_user . . | ||
COPY --chown=$USER . . | ||
|
||
USER app_user | ||
USER $USER | ||
|
||
CMD ["/usr/local/bin/gunicorn", "base_app.asgi:application", "-k", "uvicorn.workers.UvicornWorker", "--bind", "0.0.0.0:8000"] | ||
|
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from pythonjsonlogger.jsonlogger import JsonFormatter | ||
|
||
|
||
class CustomJsonFormatter(JsonFormatter): | ||
def add_fields(self, log_record, record, message_dict): # pragma: no cover | ||
super().add_fields(log_record, record, message_dict) | ||
log_record['severity'] = record.levelname |
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
Oops, something went wrong.