-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
32 lines (21 loc) · 773 Bytes
/
Dockerfile
File metadata and controls
32 lines (21 loc) · 773 Bytes
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
FROM python:3-slim-bullseye as builder
# This stage installs gcc to compile all python modules that requires it.
# We don't need gcc in final stage
WORKDIR /app
RUN apt-get update && \
apt-get install -y --no-install-recommends build-essential
COPY Pipfile .
RUN pip install pipenv
RUN python -m venv /venv
RUN . /venv/bin/activate && pipenv install --deploy
FROM python:3-slim-bullseye
# this stage contains the final code
WORKDIR /app
RUN addgroup --gid 1001 --system app && \
adduser --no-create-home --shell /bin/false --disabled-password --uid 1001 --system --group app
USER app
COPY --from=builder --chown=app:app /venv /venv
ENV PATH="/venv/bin/:${PATH}"
COPY . /app/
EXPOSE 80
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "80"]