-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rockerfile
66 lines (49 loc) · 2.64 KB
/
Rockerfile
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
################################################################################
# Build system
################################################################################
FROM debian:stretch
MOUNT /root/.cache
MOUNT /var/cache/apt
MOUNT /var/lib/apt
WORKDIR /build
RUN echo 'alias l="ls -lsah"' > ~/.bashrc \
&& apt-get -y update \
&& apt-get -y install gnupg \
&& apt-key adv --fetch-keys http://nginx.org/keys/nginx_signing.key \
&& echo "deb-src http://nginx.org/packages{{ if ne .NginxVariant "stable" }}/{{ .NginxVariant }}{{ end }}/debian/ stretch nginx" >> /etc/apt/sources.list.d/nginx.list \
&& apt-get -y update \
&& apt-get -y install dpkg-dev build-essential zlib1g-dev libpcre3 libpcre3-dev unzip uuid-dev wget clang \
&& apt-get -y build-dep nginx
RUN apt-get source nginx={{ .NginxVersion }}-1~stretch
ADD https://github.com/apache/incubator-pagespeed-ngx/archive/v{{ .PagespeedVersion }}-stable.tar.gz /build/pagespeed-{{ .PagespeedVersion }}.tar.gz
ADD https://dl.google.com/dl/page-speed/psol/{{ .PsolVersion }}-x64.tar.gz /build/psol-{{ .PsolVersion }}.tar.gz
RUN mkdir -p /build/nginx-{{ .NginxVersion }}/debian/modules \
&& ( cd /build/nginx-{{ .NginxVersion }}/debian/modules \
&& tar xzf /build/pagespeed-{{ .PagespeedVersion }}.tar.gz \
&& mv incubator-pagespeed-ngx-{{ .PagespeedVersion }}-stable ngx_pagespeed-{{ .PagespeedVersion }} ) \
&& ( cd /build/nginx-{{ .NginxVersion }}/debian/modules/ngx_pagespeed-{{ .PagespeedVersion }} \
&& tar xzf /build/psol-{{ .PsolVersion }}.tar.gz && pwd && ls -lsah )
RUN sed "/LDFLAGS /a WITH_PAGESPEED := --add-module=/build/nginx-{{ .NginxVersion }}/debian/modules/ngx_pagespeed-{{ .PagespeedVersion }}" -i /build/nginx-{{ .NginxVersion }}/debian/rules \
&& sed 's/^\s\+CFLAGS=.*$/& $(WITH_PAGESPEED)/g' -i /build/nginx-{{ .NginxVersion }}/debian/rules
RUN ( cd /build/nginx-{{ .NginxVersion }} && dpkg-buildpackage -b )
EXPORT nginx_{{ .NginxVersion }}-1~stretch_amd64.deb
################################################################################
# Runtime system
################################################################################
FROM debian:stretch
MOUNT /root/.cache
MOUNT /var/cache/apt
MOUNT /var/lib/apt
IMPORT nginx_{{ .NginxVersion }}-1~stretch_amd64.deb /tmp
RUN echo 'alias l="ls -lsah"' > ~/.bashrc \
&& apt-get update -y \
&& apt-get install -y libssl1.1 \
&& dpkg -i /tmp/nginx_{{ .NginxVersion }}-1~stretch_amd64.deb \
&& ln -sf /dev/stdout /var/log/nginx/access.log \
&& ln -sf /dev/stderr /var/log/nginx/error.log \
&& rm /tmp/*.deb
WORKDIR /var/www
EXPOSE 80 443
VOLUME ["/var/cache/nginx"]
CMD ["nginx", "-g", "daemon off;"]
PUSH {{ .DockerImage }}