forked from GoSecure/pyrdp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
80 lines (66 loc) · 2.63 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# Handles compiling and package installation
FROM ubuntu:20.04 AS compile-image
# Install build dependencies
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
python3 python3-pip \
# Required for local pip install
python3-setuptools \
# Required for venv setup
python3-venv \
# Required to build RLE module and dbus-python (GUI)
build-essential python3-dev \
libdbus-1-dev libdbus-glib-1-dev \
# Required to build PyAV (pyrdp-convert to MP4)
libavformat-dev libavcodec-dev libavdevice-dev \
libavutil-dev libswscale-dev libswresample-dev libavfilter-dev
RUN python3 -m venv /opt/venv
# Make sure we use the virtualenv:
ENV PATH="/opt/venv/bin:$PATH"
# Install dependencies only (speeds repetitive builds)
COPY requirements.txt /pyrdp/requirements.txt
RUN cd /pyrdp && \
pip3 install wheel && \
pip3 --no-cache-dir install --default-timeout=100 -r requirements.txt
# Compile only our C extension and install
# This way changes to source tree will not trigger full images rebuilds
COPY ext/rle.c /pyrdp/ext/rle.c
COPY setup.py /pyrdp/setup.py
RUN cd /pyrdp \
&& python setup.py build_ext \
&& python setup.py install_lib
# Handles runtime only (minimize size for distribution)
FROM ubuntu:20.04 AS docker-image
# Install runtime dependencies except pre-built venv
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends python3 \
# To generate certificates
openssl \
# Required for the setup.py install and progressbar (required by pyrdp-convert)
python3-distutils \
# GUI and notifications stuff
libgl1-mesa-glx libxcb-xinerama0 \
notify-osd dbus-x11 libxkbcommon-x11-0 \
# Runtime requirement for PyAV (pyrdp-convert to MP4)
libavcodec58 libavdevice58 \
&& rm -rf /var/lib/apt/lists/*
# Copy preinstalled dependencies from compile image
COPY --from=compile-image /opt/venv /opt/venv
# Create user
RUN useradd --create-home --home-dir /home/pyrdp pyrdp
# Make sure we use the virtualenv
ENV PATH="/opt/venv/bin:$PATH"
# Install python source and package
# NOTE: we are no longer doing this in the compile image to avoid long image rebuilds in development
COPY --from=compile-image /pyrdp /pyrdp
COPY bin/ /pyrdp/bin/
COPY pyrdp/ /pyrdp/pyrdp/
COPY setup.py /pyrdp/setup.py
RUN cd /pyrdp \
&& python setup.py install
USER pyrdp
# UTF-8 support on the console output (for pyrdp-player)
ENV PYTHONIOENCODING=utf-8
# Make sure we use the virtualenv
ENV PATH="/opt/venv/bin:$PATH"
WORKDIR /home/pyrdp