-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
50 lines (33 loc) · 1.13 KB
/
Dockerfile
File metadata and controls
50 lines (33 loc) · 1.13 KB
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
47
48
49
50
FROM python:3.11-slim as poetry
ENV PATH "/root/.local/bin:${PATH}"
ENV PYTHONUNBUFFERED 1
WORKDIR /root
# see DOK-DL4006
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN apt-get update && \
apt-get install curl -y --no-install-recommends && \
curl -sSL https://install.python-poetry.org | python -
COPY poetry.lock pyproject.toml ./
RUN poetry export --no-interaction -o requirements.txt --without-hashes --only main,docker
FROM python:3.11-slim as base
ENV PYTHONPATH "/app"
WORKDIR /app
RUN groupadd -g 5000 container && useradd -d /app -m -g container -u 5000 container
RUN apt-get update && \
apt-get install git -y --no-install-recommends && \
apt-get clean
COPY --from=poetry /root/requirements.txt ./
RUN pip install --no-cache-dir -U pip && \
pip --no-cache-dir install -r requirements.txt
COPY src/ src/
FROM base AS git
# Save build version
COPY .git .git
RUN git rev-parse HEAD > /commit.txt
FROM base AS final
COPY --from=git /commit.txt commit.txt
RUN chown -R 5000:5000 /app
USER container
ENV PROD 1
VOLUME /app/data
CMD ["dumb-init", "uvicorn", "src.app:app", "--host", "0.0.0.0", "--port", "8000"]