-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
46 lines (26 loc) · 769 Bytes
/
Dockerfile
File metadata and controls
46 lines (26 loc) · 769 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
FROM python:3.8 AS build
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
RUN python -m venv /opt/venv
ENV PATH=/opt/venv/bin:$PATH
COPY requirements.txt /tmp/requirements.txt
RUN /opt/venv/bin/pip install -r /tmp/requirements.txt
COPY /app /opt/app
WORKDIR /opt
CMD ["python", "/opt/app/main.py"]
#------
FROM build as validate
COPY requirements-dev.txt /tmp/requirements-dev.txt
RUN /opt/venv/bin/pip install -r /tmp/requirements-dev.txt
COPY /tests /opt/tests
#------
FROM python:3.8-slim
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
COPY --from=build /opt /opt
ENV PATH=/opt/venv/bin:$PATH
RUN groupadd -g 999 appusr && \
useradd -r -d /opt/app -u 999 -g appusr appusr
WORKDIR /opt
USER appusr
CMD ["python", "/opt/app/main.py"]