1
+ # NOTE: this example is taken from the default Dockerfile for the official nginx Docker Hub Repo
2
+ # https://hub.docker.com/_/nginx/
3
+ # NOTE: This file is slightly different than the video, because nginx versions have been updated
4
+ # to match the latest standards from docker hub... but it's doing the same thing as the video
5
+ # describes
6
+ FROM debian:stretch-slim
7
+ # all images must have a FROM
8
+ # usually from a minimal Linux distribution like debian or (even better) alpine
9
+ # if you truly want to start with an empty container, use FROM scratch
10
+
11
+ ENV NGINX_VERSION 1.13.6-1~stretch
12
+ ENV NJS_VERSION 1.13.6.0.1.14-1~stretch
13
+ # optional environment variable that's used in later lines and set as envvar when container is running
14
+
15
+ RUN apt-get update \
16
+ && apt-get install --no-install-recommends --no-install-suggests -y gnupg1 \
17
+ && \
18
+ NGINX_GPGKEY=573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62; \
19
+ found='' ; \
20
+ for server in \
21
+ ha.pool.sks-keyservers.net \
22
+ hkp://keyserver.ubuntu.com:80 \
23
+ hkp://p80.pool.sks-keyservers.net:80 \
24
+ pgp.mit.edu \
25
+ ; do \
26
+ echo "Fetching GPG key $NGINX_GPGKEY from $server" ; \
27
+ apt-key adv --keyserver "$server" --keyserver-options timeout=10 --recv-keys "$NGINX_GPGKEY" && found=yes && break; \
28
+ done; \
29
+ test -z "$found" && echo >&2 "error: failed to fetch GPG key $NGINX_GPGKEY" && exit 1; \
30
+ apt-get remove --purge -y gnupg1 && apt-get -y --purge autoremove && rm -rf /var/lib/apt/lists/* \
31
+ && echo "deb http://nginx.org/packages/mainline/debian/ stretch nginx" >> /etc/apt/sources.list \
32
+ && apt-get update \
33
+ && apt-get install --no-install-recommends --no-install-suggests -y \
34
+ nginx=${NGINX_VERSION} \
35
+ nginx-module-xslt=${NGINX_VERSION} \
36
+ nginx-module-geoip=${NGINX_VERSION} \
37
+ nginx-module-image-filter=${NGINX_VERSION} \
38
+ nginx-module-njs=${NJS_VERSION} \
39
+ gettext-base \
40
+ && rm -rf /var/lib/apt/lists/*
41
+ # optional commands to run at shell inside container at build time
42
+ # this one adds package repo for nginx from nginx.org and installs it
43
+
44
+ RUN ln -sf /dev/stdout /var/log/nginx/access.log \
45
+ && ln -sf /dev/stderr /var/log/nginx/error.log
46
+ # forward request and error logs to docker log collector
47
+
48
+ EXPOSE 80 443
49
+ # expose these ports on the docker virtual network
50
+ # you still need to use -p or -P to open/forward these ports on host
51
+
52
+ CMD ["nginx" , "-g" , "daemon off;" ]
53
+ # required: run this command when container is launched
54
+ # only one CMD allowed, so if there are multiple, last one wins
0 commit comments