-
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.
Add Dockerfile for NGINX Open Source for Openshift
- Loading branch information
Raul Marrero
committed
Mar 24, 2020
1 parent
2da6bf9
commit c8f5ec9
Showing
2 changed files
with
63 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
ARG GOLANG_CONTAINER=registry.access.redhat.com/ubi8/go-toolset:latest | ||
|
||
FROM registry.access.redhat.com/ubi8/ubi:8.1 AS base | ||
|
||
ENV NGINX_VERSION=1.17.9 | ||
|
||
RUN set -x \ | ||
&& groupadd --system --gid 101 nginx \ | ||
&& useradd --system --gid nginx --no-create-home --home-dir /nonexistent --comment "nginx user" --shell /bin/false --uid 101 nginx \ | ||
&& echo "[nginx]" >> /etc/yum.repos.d/nginx.repo \ | ||
&& echo "name=nginx repo" >> /etc/yum.repos.d/nginx.repo \ | ||
&& echo "baseurl=https://nginx.org/packages/mainline/rhel/8/\$basearch/" >> /etc/yum.repos.d/nginx.repo \ | ||
&& echo "gpgcheck=0" >> /etc/yum.repos.d/nginx.repo \ | ||
&& echo "enabled=1" >> /etc/yum.repos.d/nginx.repo \ | ||
&& echo "module_hotfixes=true" >> /etc/yum.repos.d/nginx.repo \ | ||
&& yum update -y \ | ||
&& yum install -y nginx-${NGINX_VERSION} \ | ||
&& nginx \ | ||
&& mkdir -p /var/lib/nginx \ | ||
&& mkdir -p /etc/nginx/secrets \ | ||
&& setcap 'cap_net_bind_service=+ep' /usr/sbin/nginx \ | ||
&& setcap 'cap_net_bind_service=+ep' /usr/sbin/nginx-debug \ | ||
&& chown -R nginx:0 /etc/nginx \ | ||
&& chown -R nginx:0 /var/cache/nginx \ | ||
&& chown -R nginx:0 /var/lib/nginx \ | ||
&& rm /etc/yum.repos.d/nginx.repo \ | ||
&& rm /etc/nginx/conf.d/* | ||
|
||
# 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 | ||
|
||
COPY internal/configs/version1/nginx.ingress.tmpl \ | ||
internal/configs/version1/nginx.tmpl \ | ||
internal/configs/version2/nginx.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"] | ||
|
||
|
||
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 / |
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