-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
31 lines (23 loc) · 826 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
FROM python:3.12-slim as builder
RUN useradd -rm -d /home/user -u 1001 user && \
mkdir -p /home/user/app && \
chown -R user /home/user/app
USER user
WORKDIR /home/user/
COPY app.py poetry.lock pyproject.toml README.md app/
COPY src/ app/src/
WORKDIR /home/user/app
RUN pip install poetry==1.8.1 --user --no-cache-dir && \
export PATH="${PATH}":"${HOME}"/.local/bin && \
poetry config virtualenvs.in-project true && \
poetry install --only main
FROM python:3.12-slim
RUN useradd -rm -d /home/user -u 1001 user && \
mkdir -p /home/user/app && \
chown -R user /home/user/app
USER user
COPY --from=builder /home/user/app/ /home/user/app/
ENV PATH=/home/user/app/.venv/bin:$PATH
ENV PYTHONUNBUFFERED 1
WORKDIR /home/user/app
CMD ["uvicorn", "src.main:app", "--host", "0.0.0.0", "--port", "8020"]