-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathDockerfile
46 lines (35 loc) · 960 Bytes
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
FROM python:3.12.1-slim as base
ENV PYTHONUNBUFFERED=1
# Build stage - build server as wheel
FROM base as builder
ENV PIP_DISABLE_PIP_VERSION_CHECK=1 \
PIP_NO_CACHE_DIR=1 \
POETRY_VERSION=1.7.1
RUN apt-get update && apt-get install -y \
build-essential \
gcc \
git \
libpq-dev \
openssh-client \
&& rm -rf /var/lib/apt/lists/*
RUN pip install "poetry==$POETRY_VERSION"
RUN python -m venv /venv
COPY /app /app
COPY pyproject.toml /
COPY poetry.lock /
RUN --mount=type=ssh poetry build && /venv/bin/pip install dist/*.whl
# Run stage - copy venv and run
FROM base as final
COPY --from=builder /venv /venv
ENV PATH="/venv/bin:$PATH"
RUN apt-get update && apt-get install -y libpq-dev \
&& rm -rf /var/lib/apt/lists/*
COPY /alembic /alembic
COPY alembic.ini /
COPY migrate.py /
CMD exec gunicorn \
--bind :$PORT \
--workers 3 \
-k uvicorn.workers.UvicornWorker \
--access-logfile - \
app.main:app