-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDockerfile-buster
159 lines (144 loc) · 4.43 KB
/
Dockerfile-buster
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# -*- coding: utf-8 -*-
#
# This software may be modified and distributed under the terms
# of the MIT license. See the LICENSE file for details.
#
# Multistage Dockerfile to build a Python 3.8 image based on Debian Buster.
# Inspired by https://github.com/docker-library/python/blob/master/3.8/buster/slim/Dockerfile
# Notable changes:
# - adapted to multistage build
# - removed cleanup steps in builder image for readibility
# - build without tk, ncurses and readline
FROM debian:buster-slim
ENV DEBIAN_FRONTEND=noninteractive \
LANG=C.UTF-8 \
PATH=/usr/local/bin:$PATH \
PYTHON_VERSION=3.8.3 \
PYTHON_PIP_VERSION=20.1.1 \
PYTHON_GET_PIP_URL=https://bootstrap.pypa.io/get-pip.py \
PYTHON_GET_PIP_SHA256=b3153ec0cf7b7bbf9556932aa37e4981c35dc2a2c501d70d91d2795aa532be79 \
PYTHON_GPG_KEY=E3FF2839C048B25C084DEBE9B26995E310250568
RUN set -ex && \
apt-get update && apt-get install --assume-yes --no-install-recommends \
bash \
ca-certificates \
curl \
dirmngr \
dpkg-dev \
findutils \
gcc \
git \
gnupg \
jq \
libbz2-dev \
libc6-dev \
libexpat1-dev \
libffi-dev \
libjpeg-dev \
liblzma-dev \
libsqlite3-dev \
libssl-dev \
libxml2 \
libxml2-dev \
libxslt-dev \
make \
musl \
neofetch \
netbase \
pv \
sudo \
tar \
uuid-dev \
wget \
xz-utils \
zip \
zlib1g-dev
RUN wget --no-verbose --output-document=python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz" \
&& wget --no-verbose --output-document=python.tar.xz.asc "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc" \
&& $(command -v gpg > /dev/null || echo 'gnupg dirmngr') \
&& export GNUPGHOME="$(mktemp -d)" \
&& gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys "$PYTHON_GPG_KEY" \
&& gpg --batch --verify python.tar.xz.asc python.tar.xz \
&& { command -v gpgconf > /dev/null && gpgconf --kill all || :; } \
&& rm -rf "$GNUPGHOME" python.tar.xz.asc \
&& mkdir -p /usr/src/python \
&& tar -xJC /usr/src/python --strip-components=1 -f python.tar.xz \
&& rm python.tar.xz
RUN cd /usr/src/python \
&& gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" \
&& ./configure --help \
&& ./configure \
--build="$gnuArch" \
--prefix="/python" \
--enable-loadable-sqlite-extensions \
--enable-optimizations \
--enable-ipv6 \
--disable-shared \
--with-system-expat \
--with-system-ffi \
--without-ensurepip \
&& make -j "$(nproc)" \
LDFLAGS="-Wl,--strip-all" \
&& make install
RUN strip /python/bin/python3.8 && \
strip --strip-unneeded /python/lib/python3.8/config-3.8-x86_64-linux-gnu/libpython3.8.a && \
strip --strip-unneeded /python/lib/python3.8/lib-dynload/*.so && \
rm /python/lib/libpython3.8.a && \
ln /python/lib/python3.8/config-3.8-x86_64-linux-gnu/libpython3.8.a /python/lib/libpython3.8.a
RUN set -ex; \
\
wget --no-verbose --output-document=get-pip.py "$PYTHON_GET_PIP_URL"; \
echo "$PYTHON_GET_PIP_SHA256 *get-pip.py" | sha256sum --check --strict -; \
\
/python/bin/python3 get-pip.py \
--disable-pip-version-check \
--no-cache-dir \
"pip==$PYTHON_PIP_VERSION"
RUN ln -s /python/bin/python3-config /usr/local/bin/python-config && \
ln -s /python/bin/python3 /usr/local/bin/python && \
ln -s /python/bin/python3 /usr/local/bin/python3 && \
ln -s /python/bin/pip3 /usr/local/bin/pip && \
ln -s /python/bin/pip3 /usr/local/bin/pip3
# One4u
RUN set -ex && \
apt-get install --assume-yes --no-install-recommends \
aria2 \
chromium \
chromium-driver \
ffmpeg \
figlet \
libfreetype6 \
libfreetype6-dev \
libevent-dev \
libpq-dev \
megatools \
nodejs \
postgresql \
postgresql-contrib \
postgresql-client \
python-psycopg2
ADD https://raw.githubusercontent.com/MoveAngel/One4uBot/sql-extended/requirements.txt requirements.txt
RUN pip install --no-cache-dir -r requirements.txt
RUN set -ex; \
\
find /python/lib -type d -a \( \
-name test -o \
-name tests -o \
-name idlelib -o \
-name turtledemo -o \
-name pydoc_data -o \
-name tkinter \) -exec rm -rf {} +; \
\
find /usr/local -depth \
\( \
\( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \
-o \
\( -type f -a \( -name '*.pyc' -o -name '*.pyo' \) \) \
\) -exec rm -rf '{}' +; \
\
apt-get purge --assume-yes --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
rm -rf /var/lib/apt/lists/*; \
rm -rf /usr/src/python; \
rm -f /get-pip.py; \
rm -f /requirements.txt
CMD ["python3"]