forked from pyload/pyload
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.alpine
131 lines (90 loc) · 3.52 KB
/
Dockerfile.alpine
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# Highly-Optimized Docker Image of pyLoad (alpine variant)
# AUTHOR: vuolter
# ____________
# _ / | \ ___________ _ _______________ _ ___ _______________
# / | ___/ | _ __ _ _| | ___ __ _ __| | \\ ___ ___ _\
# / \___/ ______/ | '_ \ || | |__/ _ \/ _` / _` | \\ / _ \/ _ `/ \
# \ | o| | .__/\_, |____\___/\__,_\__,_| // /_//_/\_, / /
# \______\ /______|_|___|__/________________________//______ /___/__/
# \ /
# \/
ARG ALPINE_RELEASE="3.10"
FROM lsiobase/alpine:$ALPINE_RELEASE as builder
ARG APK_INSTALL_OPTIONS="--no-cache"
ARG PIP_INSTALL_OPTIONS="--disable-pip-version-check --no-cache-dir --no-compile --upgrade"
ARG APK_PACKAGES="python3 openssl"
ARG PIP_PACKAGES="pip setuptools wheel"
RUN \
echo "**** install Python ****" && \
apk add $APK_INSTALL_OPTIONS $APK_PACKAGES && \
ln -sf python3 /usr/bin/python && \
\
echo "**** install pip ****" && \
python3 -m ensurepip && rm -rf /usr/lib/python*/ensurepip && \
pip3 install $PIP_INSTALL_OPTIONS $PIP_PACKAGES && \
ln -sf pip3 /usr/bin/pip
FROM builder as wheels_builder
COPY setup.cfg /source/setup.cfg
WORKDIR /wheels
ARG APK_INSTALL_OPTIONS="--no-cache"
ARG APK_PACKAGES="gcc musl-dev python3-dev libffi-dev openssl-dev jpeg-dev zlib-dev libxml2-dev libxslt-dev"
RUN \
echo "**** install build packages ****" && \
apk add $APK_INSTALL_OPTIONS $APK_PACKAGES && \
\
echo "**** build pyLoad dependencies ****" && \
python -c "import configparser as cp; c = cp.ConfigParser(); c.read('/source/setup.cfg'); print(c['options']['install_requires'] + c['options.extras_require']['extra'])" | \
xargs pip wheel --wheel-dir=.
FROM builder as source_builder
COPY . /source
WORKDIR /source
ARG PIP_INSTALL_OPTIONS="--disable-pip-version-check --no-cache-dir --no-compile --upgrade"
ARG PIP_PACKAGES="Babel Jinja2"
RUN \
echo "**** build pyLoad locales ****" && \
pip install $PIP_INSTALL_OPTIONS $PIP_PACKAGES && \
python setup.py build_locale
FROM builder as package_builder
COPY --from=wheels_builder /wheels /wheels
COPY --from=source_builder /source /source
WORKDIR /package
ARG PIP_INSTALL_OPTIONS="--disable-pip-version-check --no-cache-dir --no-compile --upgrade"
RUN \
echo "**** build pyLoad package ****" && \
pip install $PIP_INSTALL_OPTIONS --find-links=/wheels --no-index --prefix=. /source[extra]
FROM builder
LABEL \
version="1.0" \
description="The free and open-source Download Manager written in pure Python" \
maintainer="[email protected]"
# Set Python to force stdin, stdout and stderr to be totally unbuffered.
# Stop if any script (fix-attrs or cont-init) has failed.
# Set Python to use UTF-8 encoding rather than ASCII.
ENV \
PYTHONUNBUFFERED=1 \
S6_BEHAVIOUR_IF_STAGE2_FAILS=2 \
LANG=C.UTF-8
ARG APK_INSTALL_OPTIONS="--no-cache"
ARG APK_PACKAGES="sqlite tesseract-ocr unrar"
ARG TEMP_PATHS="/root/.cache /tmp/* /var/tmp/*"
RUN \
echo "**** install binary packages ****" && \
apk add $APK_INSTALL_OPTIONS $APK_PACKAGES && \
\
echo "**** create s6 fix-attr script ****" && \
echo -e "/config true abc 0644 0755\n \
/downloads false abc 0644 0755" > /etc/fix-attrs.d/10-run && \
\
echo "**** create s6 service script ****" && \
mkdir -p /etc/services.d/pyload && \
echo -e "#!/usr/bin/with-contenv bash\n\n \
umask 022\n \
exec s6-setuidgid abc pyload --userdir /config --storagedir /downloads" > /etc/services.d/pyload/run && \
\
echo "**** cleanup ****" && \
rm -rf $TEMP_PATHS && \
\
echo "**** finalize pyLoad ****"
COPY --from=package_builder /package /usr/local
EXPOSE 8001 9666
VOLUME /config /downloads