-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
40 lines (28 loc) · 966 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
FROM python:3.11-slim AS builder
ENV POETRY_HOME="/opt/poetry" \
POETRY_VIRTUALENVS_IN_PROJECT=1 \
POETRY_NO_INTERACTION=1
# to run poetry directly as soon as it's installed
ENV PATH="$POETRY_HOME/bin:$PATH"
# install poetry
RUN pip install poetry==1.8
WORKDIR /app
# copy only pyproject.toml and poetry.lock file nothing else here
COPY poetry.lock pyproject.toml ./
# this will create the folder /app/.venv (might need adjustment depending on which poetry version you are using)
RUN poetry install --no-root --no-ansi --without test
FROM python:3.11-slim AS runtime
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PATH="/app/.venv/bin:$PATH"
WORKDIR /app
# Install openCV related packages
RUN apt-get update -y && \
apt-get install -y \
libgl1-mesa-glx \
libglib2.0-0
# copy the venv folder from builder image
COPY --from=builder /app/.venv ./.venv
COPY . ./
EXPOSE 8000
CMD python -m uvicorn --host=0.0.0.0 app.main:app