Skip to content

Commit

Permalink
change ASGI server to uvicorn, use python:3.12.5-alpine3.20 as base i…
Browse files Browse the repository at this point in the history
…mage
  • Loading branch information
nitekot committed Aug 29, 2024
1 parent 90f36f5 commit 84dc648
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
FROM python:3.11-slim-buster
FROM python:3.12.5-alpine3.20 as base

RUN pip install poetry==1.8.3
ENV VIRTUAL_ENV=/project/.venv \
PATH="/project/.venv/bin:$PATH"


FROM base as builder

ENV POETRY_NO_INTERACTION=1 \
POETRY_VIRTUALENVS_IN_PROJECT=1 \
POETRY_VIRTUALENVS_CREATE=1 \
POETRY_CACHE_DIR=/tmp/poetry_cache
POETRY_CACHE_DIR=/tmp/poetry_cache \
PIP_ROOT_USER_ACTION=ignore

RUN apk add gcc python3-dev musl-dev linux-headers

RUN pip install poetry==1.8.3

WORKDIR /project

Expand All @@ -14,9 +23,17 @@ RUN touch README.md

RUN poetry install --no-root && rm -rf $POETRY_CACHE_DIR



FROM base as runtime

COPY --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV}

WORKDIR /project

COPY sync.py .
COPY aggregator.py .
COPY alembic ./alembic
COPY app ./app

CMD poetry run alembic upgrade head && poetry run gunicorn "app:create_app()" --workers 4 --worker-class uvicorn.workers.UvicornWorker -b 0.0.0.0:8000
CMD uvicorn app:create_app --host 0.0.0.0 --port 8000

0 comments on commit 84dc648

Please sign in to comment.