-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Convert spaces in Dockerfiles to tabs * Add multi stage docker builds
- Loading branch information
1 parent
e8030d1
commit ce3271e
Showing
9 changed files
with
276 additions
and
180 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
FROM debian:stretch-slim | ||
ARG GOLANG_CONTAINER=golang:latest | ||
|
||
FROM debian:stretch-slim AS base | ||
|
||
LABEL maintainer="NGINX Docker Maintainers <[email protected]>" | ||
|
||
|
@@ -7,66 +9,84 @@ ARG IC_VERSION | |
|
||
# Download certificate and key from the customer portal (https://cs.nginx.com) | ||
# and copy to the build context | ||
COPY nginx-repo.crt /etc/ssl/nginx/ | ||
COPY nginx-repo.key /etc/ssl/nginx/ | ||
COPY nginx-repo.crt nginx-repo.key /etc/ssl/nginx/ | ||
|
||
# Make sure the certificate and key have correct permissions | ||
RUN chmod 644 /etc/ssl/nginx/* | ||
|
||
# Install NGINX Plus | ||
RUN set -x \ | ||
&& apt-get update \ | ||
&& apt-get install --no-install-recommends --no-install-suggests -y apt-transport-https ca-certificates gnupg1 libcap2-bin \ | ||
&& \ | ||
NGINX_GPGKEY=573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62; \ | ||
found=''; \ | ||
for server in \ | ||
ha.pool.sks-keyservers.net \ | ||
hkp://keyserver.ubuntu.com:80 \ | ||
hkp://p80.pool.sks-keyservers.net:80 \ | ||
pgp.mit.edu \ | ||
; do \ | ||
echo "Fetching GPG key $NGINX_GPGKEY from $server"; \ | ||
apt-key adv --keyserver "$server" --keyserver-options timeout=10 --recv-keys "$NGINX_GPGKEY" && found=yes && break; \ | ||
done; \ | ||
test -z "$found" && echo >&2 "error: failed to fetch GPG key $NGINX_GPGKEY" && exit 1; \ | ||
echo "Acquire::https::plus-pkgs.nginx.com::Verify-Peer \"true\";" >> /etc/apt/apt.conf.d/90nginx \ | ||
&& echo "Acquire::https::plus-pkgs.nginx.com::Verify-Host \"true\";" >> /etc/apt/apt.conf.d/90nginx \ | ||
&& echo "Acquire::https::plus-pkgs.nginx.com::SslCert \"/etc/ssl/nginx/nginx-repo.crt\";" >> /etc/apt/apt.conf.d/90nginx \ | ||
&& echo "Acquire::https::plus-pkgs.nginx.com::SslKey \"/etc/ssl/nginx/nginx-repo.key\";" >> /etc/apt/apt.conf.d/90nginx \ | ||
&& echo "Acquire::https::plus-pkgs.nginx.com::User-Agent \"k8s-ic-$IC_VERSION-apt\";" >> /etc/apt/apt.conf.d/90nginx \ | ||
&& printf "deb https://plus-pkgs.nginx.com/debian stretch nginx-plus\n" > /etc/apt/sources.list.d/nginx-plus.list \ | ||
&& apt-get update && apt-get install -y nginx-plus=${NGINX_PLUS_VERSION} \ | ||
&& setcap 'cap_net_bind_service=+ep' /usr/sbin/nginx \ | ||
&& setcap 'cap_net_bind_service=+ep' /usr/sbin/nginx-debug \ | ||
&& apt-get remove --purge --auto-remove -y gnupg1 \ | ||
&& rm -rf /var/lib/apt/lists/* \ | ||
&& rm -rf /etc/ssl/nginx \ | ||
&& rm /etc/apt/apt.conf.d/90nginx /etc/apt/sources.list.d/nginx-plus.list | ||
&& apt-get update \ | ||
&& apt-get install --no-install-recommends --no-install-suggests -y apt-transport-https ca-certificates gnupg1 libcap2-bin \ | ||
&& \ | ||
NGINX_GPGKEY=573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62; \ | ||
found=''; \ | ||
for server in \ | ||
ha.pool.sks-keyservers.net \ | ||
hkp://keyserver.ubuntu.com:80 \ | ||
hkp://p80.pool.sks-keyservers.net:80 \ | ||
pgp.mit.edu \ | ||
; do \ | ||
echo "Fetching GPG key $NGINX_GPGKEY from $server"; \ | ||
apt-key adv --keyserver "$server" --keyserver-options timeout=10 --recv-keys "$NGINX_GPGKEY" && found=yes && break; \ | ||
done; \ | ||
test -z "$found" && echo >&2 "error: failed to fetch GPG key $NGINX_GPGKEY" && exit 1; \ | ||
echo "Acquire::https::plus-pkgs.nginx.com::Verify-Peer \"true\";" >> /etc/apt/apt.conf.d/90nginx \ | ||
&& echo "Acquire::https::plus-pkgs.nginx.com::Verify-Host \"true\";" >> /etc/apt/apt.conf.d/90nginx \ | ||
&& echo "Acquire::https::plus-pkgs.nginx.com::SslCert \"/etc/ssl/nginx/nginx-repo.crt\";" >> /etc/apt/apt.conf.d/90nginx \ | ||
&& echo "Acquire::https::plus-pkgs.nginx.com::SslKey \"/etc/ssl/nginx/nginx-repo.key\";" >> /etc/apt/apt.conf.d/90nginx \ | ||
&& echo "Acquire::https::plus-pkgs.nginx.com::User-Agent \"k8s-ic-$IC_VERSION-apt\";" >> /etc/apt/apt.conf.d/90nginx \ | ||
&& printf "deb https://plus-pkgs.nginx.com/debian stretch nginx-plus\n" > /etc/apt/sources.list.d/nginx-plus.list \ | ||
&& apt-get update && apt-get install -y nginx-plus=${NGINX_PLUS_VERSION} \ | ||
&& setcap 'cap_net_bind_service=+ep' /usr/sbin/nginx \ | ||
&& setcap 'cap_net_bind_service=+ep' /usr/sbin/nginx-debug \ | ||
&& apt-get remove --purge --auto-remove -y gnupg1 \ | ||
&& rm -rf /var/lib/apt/lists/* \ | ||
&& rm -rf /etc/ssl/nginx \ | ||
&& rm /etc/apt/apt.conf.d/90nginx /etc/apt/sources.list.d/nginx-plus.list | ||
|
||
|
||
# forward nginx access and error logs to stdout and stderr of the ingress | ||
# controller process | ||
RUN ln -sf /proc/1/fd/1 /var/log/nginx/access.log \ | ||
&& ln -sf /proc/1/fd/1 /var/log/nginx/stream-access.log \ | ||
&& ln -sf /proc/1/fd/2 /var/log/nginx/error.log | ||
&& ln -sf /proc/1/fd/1 /var/log/nginx/stream-access.log \ | ||
&& ln -sf /proc/1/fd/2 /var/log/nginx/error.log | ||
|
||
RUN mkdir -p /var/lib/nginx \ | ||
&& mkdir -p /etc/nginx/secrets \ | ||
&& chown -R nginx:0 /etc/nginx \ | ||
&& chown -R nginx:0 /var/cache/nginx \ | ||
&& chown -R nginx:0 /var/lib/nginx/ \ | ||
&& apt-get remove --purge -y libcap2-bin \ | ||
&& rm /etc/nginx/conf.d/* | ||
RUN mkdir -p /var/lib/nginx \ | ||
&& mkdir -p /etc/nginx/secrets \ | ||
&& chown -R nginx:0 /etc/nginx \ | ||
&& chown -R nginx:0 /var/cache/nginx \ | ||
&& chown -R nginx:0 /var/lib/nginx/ \ | ||
&& apt-get remove --purge -y libcap2-bin \ | ||
&& rm /etc/nginx/conf.d/* | ||
|
||
EXPOSE 80 443 | ||
|
||
COPY nginx-ingress internal/configs/version1/nginx-plus.ingress.tmpl internal/configs/version1/nginx-plus.tmpl internal/configs/version2/nginx-plus.virtualserver.tmpl / | ||
COPY internal/configs/version1/nginx-plus.ingress.tmpl \ | ||
internal/configs/version1/nginx-plus.tmpl \ | ||
internal/configs/version2/nginx-plus.virtualserver.tmpl / | ||
|
||
# Uncomment the line below if you would like to add the default.pem to the image | ||
# and use it as a certificate and key for the default server | ||
# ADD default.pem /etc/nginx/secrets/default | ||
|
||
USER nginx | ||
|
||
ENTRYPOINT ["/nginx-ingress"] | ||
ENTRYPOINT ["/nginx-ingress"] | ||
|
||
|
||
FROM base AS local | ||
COPY nginx-ingress / | ||
|
||
|
||
FROM $GOLANG_CONTAINER AS builder | ||
ARG VERSION | ||
ARG GIT_COMMIT | ||
WORKDIR /go/src/github.com/nginxinc/kubernetes-ingress/nginx-ingress/cmd/nginx-ingress | ||
COPY . /go/src/github.com/nginxinc/kubernetes-ingress/nginx-ingress/ | ||
RUN CGO_ENABLED=0 GOFLAGS='-mod=vendor' \ | ||
go build -installsuffix cgo -ldflags "-w -X main.version=${VERSION} -X main.gitCommit=${GIT_COMMIT}" -o /nginx-ingress | ||
|
||
|
||
FROM base AS container | ||
COPY --from=builder /nginx-ingress / |
Oops, something went wrong.