From ea0c1802819200ac1ec3222fadfe29c4ef6be464 Mon Sep 17 00:00:00 2001 From: Harpo Date: Wed, 21 Feb 2024 14:01:54 -0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8D=BC=20Ensure=20pip=20(#195)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Installs pip into .venv python * Black format with new version --- Dockerfile | 12 +++++++++--- chowda/fields.py | 12 ++++++------ 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index a327ce8..b84fa8c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -55,15 +55,20 @@ CMD poetry run locust ########################### -# 'production' build stage +# 'base' build stage for production ############################ FROM base as build RUN apt update && apt install -y gcc libpq-dev git RUN pdm config venv.with_pip True - RUN pdm install -G production +# Install pip into the virtual environment +RUN /app/.venv/bin/python -m ensurepip + +########################### +# 'production' final production image +############################ FROM python:3.11-slim as production WORKDIR /app @@ -76,7 +81,8 @@ COPY templates templates COPY static static ENV CHOWDA_ENV=production -ENV PATH=/app/.venv/bin/:$PATH +ENV PATH="/app/.venv/bin:$PATH" EXPOSE 8000 + CMD gunicorn chowda.app:app -b 0.0.0.0:8000 -w 2 --worker-class uvicorn.workers.UvicornWorker diff --git a/chowda/fields.py b/chowda/fields.py index fd13c03..e872a2b 100644 --- a/chowda/fields.py +++ b/chowda/fields.py @@ -95,12 +95,12 @@ async def serialize_value( return [ { **run, - 'finished_at': run['finished_at'].isoformat() - if run.get('finished_at') - else None, - 'created_at': run['created_at'].isoformat() - if run.get('created_at') - else None, + 'finished_at': ( + run['finished_at'].isoformat() if run.get('finished_at') else None + ), + 'created_at': ( + run['created_at'].isoformat() if run.get('created_at') else None + ), } for run in value ]