-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
45 lines (34 loc) · 1.09 KB
/
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
#### BUILD ENV ####
FROM python:3.9.10-slim-bullseye AS build
ENV DEBIAN_FRONTEND=noninteractive
RUN echo 'Acquire::Check-Valid-Until "false";\n\
Acquire::Check-Date "false";' > /etc/apt/apt.conf.d/10no--check-valid-until && \
apt-get update && \
apt-get install -yq --no-install-recommends \
build-essential \
&& \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Setup venv
ENV VIRTUAL_ENV=/opt/venv
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
RUN python3 -m venv $VIRTUAL_ENV && \
pip3 install --no-cache-dir --upgrade pip==22.0.4
# Install dependencies
COPY service/requirements.txt /tmp/
RUN pip3 install --no-cache-dir -r /tmp/requirements.txt
#### PRODCUTION ENV ####
FROM python:3.9.10-slim-bullseye AS production
ENV DEBIAN_FRONTEND=noninteractive
ENV VIRTUAL_ENV=/opt/venv
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
RUN apt-get update && apt-get upgrade -y
COPY --from=build /opt/venv /opt/venv
# Copy code
COPY service /service/
WORKDIR /service
USER nobody:nogroup
ARG VERSION
ENV VERSION=${VERSION}
EXPOSE 8000
CMD ["uvicorn", "main:app", "--reload", "--host", "0.0.0.0"]