-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathDockerfile-debian.template
105 lines (96 loc) · 2.6 KB
/
Dockerfile-debian.template
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
FROM debian:%%DEBIAN_SUITE%%
# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added
RUN set -eux; \
groupadd -r varnish; \
for user in varnish vcache; do \
useradd -r -g varnish $user; \
done
# prevent Debian's Varnish packages from being installed
RUN set -eux; \
{ \
echo 'Package: varnish*'; \
echo 'Pin: release *'; \
echo 'Pin-Priority: -1'; \
} > /etc/apt/preferences.d/no-debian-varnish
# dependencies required for building VMOD (Varnish modules)
ENV VMOD_BUILD_DEPS \
autoconf-archive \
automake \
autotools-dev \
libtool \
make \
pkg-config \
python3
# persistent / runtime deps
RUN apt-get update && apt-get install -y \
gcc \
libc6-dev \
--no-install-recommends && rm -r /var/lib/apt/lists/*
ENV VARNISH_VERSION %%VARNISH_VERSION%%
ENV VARNISH_URL %%VARNISH_URL%%
ENV VARNISH_SHA256 %%VARNISH_SHA256%%
RUN set -eux; \
\
fetchDeps=' \
ca-certificates \
wget \
'; \
buildDeps=" \
$VMOD_BUILD_DEPS \
dpkg-dev \
libedit-dev \
libjemalloc-dev \
libncurses5-dev \
libpcre3-dev \
"; \
savedAptMark="$(apt-mark showmanual)"; \
apt-get update; \
apt-get install -y --no-install-recommends $fetchDeps $buildDeps; \
rm -rf /var/lib/apt/lists/*; \
\
wget -O varnish.tar.gz "$VARNISH_URL"; \
\
if [ -n "$VARNISH_SHA256" ]; then \
echo "$VARNISH_SHA256 *varnish.tar.gz" | sha256sum -c -; \
fi; \
\
mkdir -p /usr/src/varnish; \
tar -zxf varnish.tar.gz -C /usr/src/varnish --strip-components=1; \
rm varnish.tar.gz; \
\
cd /usr/src/varnish; \
gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \
./autogen.sh; \
./configure \
--build="$gnuArch" \
--with-rst2man=$(command -v true) \
--with-sphinx-build=$(command -v true) \
; \
make -j "$(nproc)"; \
make install; \
ldconfig; \
\
cd /; \
rm -r /usr/src/varnish; \
\
# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies
apt-mark auto '.*' > /dev/null; \
[ -z "$savedAptMark" ] || apt-mark manual $savedAptMark; \
find /usr/local -type f -executable -exec ldd '{}' ';' \
| awk '/=>/ { print $(NF-1) }' \
| sort -u \
| xargs -r dpkg-query --search \
| cut -d: -f1 \
| sort -u \
| xargs -r apt-mark manual \
; \
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
\
varnishd -V
WORKDIR /usr/local/var/varnish
RUN chown -R varnish:varnish /usr/local/var/varnish
VOLUME /usr/local/var/varnish
COPY docker-varnish-entrypoint /usr/local/bin/
ENTRYPOINT ["docker-varnish-entrypoint"]
EXPOSE 80
CMD ["varnishd", "-F", "-f", "/usr/local/etc/varnish/default.vcl"]