-
Notifications
You must be signed in to change notification settings - Fork 1
/
DockerMake.debian.yml
267 lines (251 loc) · 10.6 KB
/
DockerMake.debian.yml
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
debian_nginx_modules_build:
build_directory: ./
FROM: python:{{ PYTHON_VERSION }}-slim-{{ DEBIAN_CODENAME }}
build: |
ARG DEBIAN_CODENAME
ARG NGINX_VERSION
ARG NGINX_NJS_VERSION
ARG NGINX_PKG_RELEASE
ENV NGINX_MODULES_DIR /usr/src/dbmisvc/output
RUN set -x \
&& tempDir="$(mktemp -d)" \
&& apt-get update \
&& apt-get install --no-install-recommends --no-install-suggests -y \
curl \
apt-transport-https \
build-essential \
software-properties-common \
zlib1g-dev \
libxml2-dev \
libxslt-dev \
libgd-dev \
libgeoip-dev \
libperl-dev \
libpcre3-dev \
libbz2-dev \
libssl-dev \
tar \
gzip \
&& cd ${tempDir} \
&& curl -fSL https://github.com/evanmiller/mod_zip/archive/master.tar.gz -o mod_zip-master.tar.gz \
&& tar xzvf mod_zip-master.tar.gz \
&& curl -f -O https://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz \
&& tar xzvf nginx-${NGINX_VERSION}.tar.gz \
&& cd nginx-${NGINX_VERSION} \
&& CONFIG="\
--prefix=/etc/nginx \
--sbin-path=/usr/sbin/nginx \
--modules-path=/usr/lib/nginx/modules \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/run/nginx.lock \
--http-client-body-temp-path=/var/cache/nginx/client_temp \
--http-proxy-temp-path=/var/cache/nginx/proxy_temp \
--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \
--http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp \
--http-scgi-temp-path=/var/cache/nginx/scgi_temp \
--user=www-data \
--group=www-data \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_sub_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_stub_status_module \
--with-http_auth_request_module \
--with-http_xslt_module=dynamic \
--with-http_image_filter_module=dynamic \
--with-http_geoip_module=dynamic \
--with-threads \
--with-stream \
--with-stream_ssl_module \
--with-stream_ssl_preread_module \
--with-stream_realip_module \
--with-stream_geoip_module=dynamic \
--with-http_slice_module \
--with-mail \
--with-mail_ssl_module \
--with-compat \
--with-file-aio \
--with-http_v2_module \
--add-dynamic-module=${tempDir}/mod_zip-master \
" \
&& ./configure --with-compat $CONFIG \
&& make modules \
&& mkdir -p ${NGINX_MODULES_DIR} \
&& cp ${tempDir}/nginx-${NGINX_VERSION}/objs/ngx_http_zip_module.so ${NGINX_MODULES_DIR}/
debian_nginx_modules_copy:
copy_from:
debian_nginx_modules_build:
/usr/src/dbmisvc/output/ngx_http_zip_module.so: /usr/lib/nginx/modules/
debian_nginx_install:
requires:
- debian_nginx_modules_copy
build: |
ARG DEBIAN_CODENAME
ARG NGINX_VERSION
ARG NGINX_NJS_VERSION
ARG NGINX_PKG_RELEASE
RUN set -x \
&& apt-get update \
&& apt-get install --no-install-recommends --no-install-suggests -y gnupg1 apt-transport-https ca-certificates \
&& \
NGINX_GPGKEY=573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62; \
NGINX_GPGKEY_PATH=/usr/share/keyrings/nginx-archive-keyring.gpg; \
export GNUPGHOME="$(mktemp -d)"; \
found=''; \
for server in \
hkp://keyserver.ubuntu.com:80 \
pgp.mit.edu \
; do \
echo "Fetching GPG key $NGINX_GPGKEY from $server"; \
gpg1 --keyserver "$server" --keyserver-options timeout=10 --recv-keys "$NGINX_GPGKEY" && found=yes && break; \
done; \
test -z "$found" && echo >&2 "error: failed to fetch GPG key $NGINX_GPGKEY" && exit 1; \
gpg1 --export "$NGINX_GPGKEY" > "$NGINX_GPGKEY_PATH" ; \
rm -rf "$GNUPGHOME"; \
apt-get remove --purge --auto-remove -y gnupg1 && rm -rf /var/lib/apt/lists/* \
&& dpkgArch="$(dpkg --print-architecture)" \
&& nginxPackages=" \
nginx=${NGINX_VERSION}-${NGINX_PKG_RELEASE}~${DEBIAN_CODENAME} \
nginx-module-xslt=${NGINX_VERSION}-${NGINX_PKG_RELEASE}~${DEBIAN_CODENAME} \
nginx-module-geoip=${NGINX_VERSION}-${NGINX_PKG_RELEASE}~${DEBIAN_CODENAME} \
nginx-module-image-filter=${NGINX_VERSION}-${NGINX_PKG_RELEASE}~${DEBIAN_CODENAME} \
nginx-module-njs=${NGINX_VERSION}+${NGINX_NJS_VERSION}-${NGINX_PKG_RELEASE}~${DEBIAN_CODENAME} \
" \
&& case "$dpkgArch" in \
amd64|arm64) \
# arches officialy built by upstream
echo "deb [signed-by=$NGINX_GPGKEY_PATH] https://nginx.org/packages/mainline/debian/ $DEBIAN_CODENAME nginx" >> /etc/apt/sources.list.d/nginx.list \
&& apt-get update \
;; \
*) \
# we're on an architecture upstream doesn't officially build for
# let's build binaries from the published source packages
echo "deb-src [signed-by=$NGINX_GPGKEY_PATH] https://nginx.org/packages/mainline/debian/ $DEBIAN_CODENAME nginx" >> /etc/apt/sources.list.d/nginx.list \
\
# new directory for storing sources and .deb files
&& tempDir="$(mktemp -d)" \
&& chmod 777 "$tempDir" \
# (777 to ensure APT's "_apt" user can access it too)
\
# save list of currently-installed packages so build dependencies can be cleanly removed later
&& savedAptMark="$(apt-mark showmanual)" \
\
# build .deb files from upstream's source packages (which are verified by apt-get)
&& apt-get update \
&& apt-get build-dep -y $nginxPackages \
&& ( \
cd "$tempDir" \
&& DEB_BUILD_OPTIONS="nocheck parallel=$(nproc)" \
apt-get source --compile $nginxPackages \
) \
# we don't remove APT lists here because they get re-downloaded and removed later
\
# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies
# (which is done after we install the built packages so we don't have to redownload any overlapping dependencies)
&& apt-mark showmanual | xargs apt-mark auto > /dev/null \
&& { [ -z "$savedAptMark" ] || apt-mark manual $savedAptMark; } \
\
# create a temporary local APT repo to install from (so that dependency resolution can be handled by APT, as it should be)
&& ls -lAFh "$tempDir" \
&& ( cd "$tempDir" && dpkg-scanpackages . > Packages ) \
&& grep '^Package: ' "$tempDir/Packages" \
&& echo "deb [ trusted=yes ] file://$tempDir ./" > /etc/apt/sources.list.d/temp.list \
# work around the following APT issue by using "Acquire::GzipIndexes=false" (overriding "/etc/apt/apt.conf.d/docker-gzip-indexes")
# Could not open file /var/lib/apt/lists/partial/_tmp_tmp.ODWljpQfkE_._Packages - open (13: Permission denied)
# ...
# E: Failed to fetch store:/var/lib/apt/lists/partial/_tmp_tmp.ODWljpQfkE_._Packages Could not open file /var/lib/apt/lists/partial/_tmp_tmp.ODWljpQfkE_._Packages - open (13: Permission denied)
&& apt-get -o Acquire::GzipIndexes=false update \
;; \
esac \
\
&& apt-get install --no-install-recommends --no-install-suggests -y \
$nginxPackages \
gettext-base \
curl \
&& apt-get remove --purge --auto-remove -y && rm -rf /var/lib/apt/lists/* /etc/apt/sources.list.d/nginx.list \
\
# if we have leftovers from building, let's purge them (including extra, unnecessary build deps)
&& if [ -n "$tempDir" ]; then \
apt-get purge -y --auto-remove \
&& rm -rf "$tempDir" /etc/apt/sources.list.d/temp.list; \
fi
debian_pip_build:
build_directory: ./
requires:
- base_meta
FROM: python:{{ PYTHON_VERSION }}-slim-{{ DEBIAN_CODENAME }}
build: |
# Install dependencies
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
g++ \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Add requirements
ADD image-requirements.txt /image-requirements.txt
RUN pip install --upgrade pip
RUN pip install -r /image-requirements.txt
debian_build:
copy_from:
debian_pip_build:
/root/.cache: /root/
build: |
ARG DEBIAN_CODENAME
# Install required packages
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
jq \
curl \
openssl \
unzip \
less \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Install security updates
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
unattended-upgrades \
debsecan \
&& apt-get install --no-install-recommends -y \
$(debsecan --suite $DEBIAN_CODENAME --format packages --only-fixed) \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& unattended-upgrade
# Set nginx user
ENV DBMI_NGINX_USER www-data
debian_prips_build:
build_directory: ./
build: |
# Download prips, build, and install
RUN BUILD_PACKAGES="build-essential" \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
apt-transport-https \
ca-certificates \
wget \
$BUILD_PACKAGES \
# Download and build prips
&& PRIPS_DIR="/tmp/prips" \
&& mkdir "$PRIPS_DIR" \
&& ( \
cd "$PRIPS_DIR" \
&& wget -c https://devel.ringlet.net/files/sys/prips/prips-1.2.0.tar.gz -O - | tar -xz \
&& cd prips-1.2.0 \
&& make \
&& cp prips /usr/local/bin \
&& chmod +x /usr/local/bin/prips \
) \
# Clean up packages
&& apt-get remove --purge --auto-remove -y $BUILD_PACKAGES \
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf "$PRIPS_DIR"