This repository has been archived by the owner on Mar 18, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
56 lines (42 loc) · 1.5 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
45
46
47
48
49
50
51
52
53
54
55
56
FROM python:3.9 AS builder
# extra dependencies (over what buildpack-deps already includes)
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc \
python3-dev
# Upgrade Pip
RUN python -m pip install --upgrade pip
# Create Python User on Container
RUN adduser --disabled-password python
USER python
WORKDIR /home/python
ENV PATH="/home/python/.local/bin:${PATH}"
# Prepare Dependencies
COPY --chown=python:python requirements.txt /home/python/wheels/requirements.txt
RUN pip wheel -r /home/python/wheels/requirements.txt -f /home/python/wheels
FROM python:3.9-slim
RUN python -m pip install --upgrade pip
# Create Python User on Container
RUN python -m pip install --upgrade pip
RUN adduser --disabled-password python
USER python
WORKDIR /home/python
ENV PATH="/home/python/.local/bin:${PATH}"
# Retrive previously build wheels
COPY --from=builder /home/python/wheels /home/python/wheels
ARG version
ARG version_long
ENV VERSION=$version
ENV VERSION_LONG=$version_long
ENV APPLICATION_VERSION=$version
ENV PATH "/opt/app/src:/root/.local:${PATH}"
ENV PYTHONPATH "/opt/app/src:/root/.local:{$PYTHONPATH}"
ENV LANG C.UTF-8
LABEL org.opencontainers.image.source=https://github.com/public-sysunicorns-info/websocket_example
EXPOSE 8080
COPY --chown=python:python requirements.txt .
RUN pip install --user -r requirements.txt -f /home/python/wheels
USER root
RUN rm -rf /home/python/wheels && rm -rf /home/python/.cache/pip/*
USER python
COPY --chown=python:python . .
CMD ["python", "./src/main.py"]