-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDockerfile-One4uBot
161 lines (146 loc) · 4.46 KB
/
Dockerfile-One4uBot
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
160
161
# -*- 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 Alpine Edge.
# Inspired by https://github.com/docker-library/python/blob/master/3.8/alpine3.12/Dockerfile
# Notable changes:
# - adapted to multistage build
# - removed cleanup steps in builder image for readibility
# - build without tk, ncurses and readline
FROM alpine:edge
ENV LANG=C.UTF-8 \
PATH=/usr/local/bin:$PATH \
PYTHON_VERSION=3.8.6 \
PYTHON_PIP_VERSION=20.2.4 \
# https://github.com/pypa/get-pip
PYTHON_GET_PIP_URL=https://github.com/pypa/get-pip/raw/fa7dc83944936bf09a0e4cb5d5ec852c0d256599/get-pip.py \
PYTHON_GET_PIP_SHA256=6e0bb0a2c2533361d7f297ed547237caf1b7507f197835974c0dd7eba998c53c \
PYTHON_GPG_KEY=E3FF2839C048B25C084DEBE9B26995E310250568
RUN set -ex && \
apk add --no-cache --update \
bash \
bzip2-dev \
ca-certificates \
coreutils \
curl \
dpkg \
dpkg-dev \
expat-dev \
findutils \
gcc \
git \
gnupg \
jq \
libc-dev \
libffi-dev \
libjpeg \
libjpeg-turbo-dev \
libwebp-dev \
libpq \
libxml2 \
libxml2-dev \
libxslt-dev \
linux-headers \
make \
musl \
neofetch \
openssl \
openssl-dev \
pv \
sqlite-dev \
sudo \
tar \
util-linux-dev \
wget \
xz \
xz-dev \
zip \
zlib-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" \
&& 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)" \
EXTRA_CFLAGS="-DTHREAD_STACK_SIZE=0x100000" \
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 sed -e 's;^#http\(.*\)/edge/community;http\1/edge/community;g' -i /etc/apk/repositories
RUN echo 'http://dl-cdn.alpinelinux.org/alpine/edge/testing' >> /etc/apk/repositories
RUN set -ex && \
apk add --no-cache --update \
aria2 \
chromium \
chromium-chromedriver \
ffmpeg \
figlet \
freetype-dev \
libevent \
megatools \
nodejs \
postgresql \
postgresql-dev \
postgresql-client
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 '{}' +; \
\
rm -rf /usr/src/python; \
rm -f /get-pip.py; \
rm -f /requirements.txt
CMD ["python3"]