-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathDockerfile-alpine.template
101 lines (92 loc) · 2.32 KB
/
Dockerfile-alpine.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
FROM alpine:%%ALPINE_VERSION%%
# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added
RUN set -eux; \
addgroup -S varnish; \
for user in varnish vcache; do \
adduser -S -G varnish $user; \
done
# dependencies required for building VMOD (Varnish modules)
ENV VMOD_BUILD_DEPS \
autoconf \
# autoconf-archive \
automake \
libtool \
make \
pkgconf \
python3
# persistent / runtime deps
RUN apk add --no-cache --virtual .persistent-deps \
gcc \
libc-dev \
libgcc
ENV VARNISH_VERSION %%VARNISH_VERSION%%
ENV VARNISH_URL %%VARNISH_URL%%
ENV VARNISH_SHA256 %%VARNISH_SHA256%%
COPY *.patch /varnish-alpine-patches/
RUN set -eux; \
\
fetchDeps=' \
ca-certificates \
wget \
'; \
buildDeps=" \
$VMOD_BUILD_DEPS \
coreutils \
dpkg \
dpkg-dev \
libedit-dev \
libexecinfo-dev \
linux-headers \
ncurses-dev \
patch \
pcre-dev \
"; \
apk add --no-cache --virtual .build-deps $fetchDeps $buildDeps; \
\
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; \
for p in /varnish-alpine-patches/*.patch; do \
[ -f "$p" ] || continue; \
patch -p1 -i "$p"; \
done; \
gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \
./autogen.sh; \
./configure \
--build="$gnuArch" \
--without-jemalloc \
--with-rst2man=$(command -v true) \
--with-sphinx-build=$(command -v true) \
; \
make -j "$(nproc)"; \
make install; \
\
cd /; \
rm -r /usr/src/varnish; \
\
runDeps="$( \
scanelf --needed --nobanner --format '%n#p' --recursive /usr/local \
| tr ',' '\n' \
| sort -u \
| awk 'system("[ -e /usr/local/lib/" $1 " ] || [ -e /usr/local/lib/varnish/" $1 " ]") == 0 { next } { print "so:" $1 }' \
)"; \
apk add --no-cache --virtual .varnish-rundeps $runDeps; \
\
apk del .build-deps; \
\
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"]