-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathDockerfile
More file actions
70 lines (54 loc) · 2.03 KB
/
Dockerfile
File metadata and controls
70 lines (54 loc) · 2.03 KB
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
# syntax=docker/dockerfile:1
FROM alpine:3 AS build-tools
# Install build tools
RUN apk add --no-cache \
build-base \
gnupg \
pcre-dev \
wget \
zlib-dev \
zlib-static
FROM build-tools AS retrieve
# Define build argument for version
ARG VERSION
ENV VERSION ${VERSION:-1.16.1}
# Retrieve and extract Nginx source archive
RUN <<EOF
wget -q http://nginx.org/download/nginx-${VERSION}.tar.gz
wget -q http://nginx.org/download/nginx-${VERSION}.tar.gz.asc
export GNUPGHOME="$(mktemp -d)"
gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys \
13C82A63B603576156E30A4EA0EA981B66B0D967
gpg --batch --verify nginx-${VERSION}.tar.gz.asc nginx-${VERSION}.tar.gz
tar xf nginx-${VERSION}.tar.gz
rm -rf "$GNUPGHOME" nginx-${VERSION}.tar.*
EOF
FROM retrieve As build
WORKDIR /nginx-${VERSION}
# Build and install nginx
RUN <<EOF
./configure --with-ld-opt="-static" --with-http_sub_module
make install
strip /usr/local/nginx/sbin/nginx
EOF
FROM alpine:3
WORKDIR /usr/local/nginx/html
# Customise static content, and configuration
COPY --from=build /usr/local/nginx /usr/local/nginx
COPY assets /usr/local/nginx/html/
COPY nginx.conf /usr/local/nginx/conf/
# Symlink access and error logs to /dev/stdout and /dev/stderr,
# in order to make use of Docker's logging mechanism
RUN <<EOF
ln -sf /dev/stdout /usr/local/nginx/logs/access.log
ln -sf /dev/stderr /usr/local/nginx/logs/error.log
EOF
# Add entrypoint script
COPY docker-entrypoint.sh /
# Change default stop signal from SIGTERM to SIGQUIT
STOPSIGNAL SIGQUIT
# Expose port
EXPOSE 80
# Define entrypoint and default parameters
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["/usr/local/nginx/sbin/nginx", "-g", "daemon off;"]