-
Notifications
You must be signed in to change notification settings - Fork 25
/
Dockerfile-nginx
84 lines (62 loc) · 2.73 KB
/
Dockerfile-nginx
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
FROM docker.io/node:20-alpine as builder
WORKDIR /hawtio-online
COPY package.json yarn.lock ./
COPY .yarnrc.yml ./
COPY packages/ packages/
COPY .yarn/plugins .yarn/plugins
COPY .yarn/releases .yarn/releases
RUN yarn install
RUN yarn build
# Build stage to extract envsubst
FROM registry.access.redhat.com/ubi9/ubi-minimal:9.4 as envsubst
RUN microdnf -y install gettext
FROM registry.access.redhat.com/ubi9/ubi-minimal:9.4
ENV NGINX_VERSION 1.20.2-1.el9
LABEL name="nginxinc/nginx" \
vendor="NGINX Inc." \
version="${NGINX_VERSION}" \
release="1" \
summary="NGINX" \
description="nginx will do ....."
## Required labels above - recommended below
LABEL url="https://www.nginx.com/" \
io.k8s.display-name="NGINX" \
io.openshift.expose-services="8443:https" \
io.openshift.tags="nginx,nginxinc"
COPY docker/nginx.repo /etc/yum.repos.d/nginx.repo
RUN curl -sO https://nginx.org/keys/nginx_signing.key && \
rpm --import ./nginx_signing.key && \
microdnf -y install --setopt=tsflags=nodocs nginx-${NGINX_VERSION}.ngx && \
rm -f ./nginx_signing.key && \
microdnf clean all
# forward request and error logs to docker log collector
# - Change pid file location & remove nginx user & change port to 8080
# - modify perms for non-root runtime
RUN ln -sf /dev/stdout /var/log/nginx/access.log && \
ln -sf /dev/stderr /var/log/nginx/error.log && \
sed -i 's~/var/run/nginx.pid~/var/cache/nginx/nginx.pid~g' /etc/nginx/nginx.conf && \
sed -i -e '/user/!b' -e '/nginx/!b' -e '/nginx/d' /etc/nginx/nginx.conf && \
sed -i 's~/var/log/nginx/error.log warn~/var/log/nginx/error.log info~g' /etc/nginx/nginx.conf && \
chown -R 998 /var/cache/nginx /etc/nginx && \
rm -f /etc/nginx/conf.d/default.conf && \
chmod -R g=u /var/cache/nginx /etc/nginx
EXPOSE 8443
## Add symbolic link to config.json to avoid mounting issues
#RUN ln -sf /usr/share/nginx/html/config.json /usr/share/nginx/html/config.json
RUN rm /usr/share/nginx/html/index.html
RUN mkdir -p /usr/share/nginx/html/online/osconsole && \
touch /usr/share/nginx/html/online/osconsole/config.json && \
chown 998 /usr/share/nginx/html/online/osconsole/config.json && \
chmod g=u /usr/share/nginx/html/online/osconsole/config.json
COPY docker/nginx-gateway.conf.template docker/osconsole/config.sh docker/nginx.sh /
# Copy include directory
COPY docker/includes /etc/nginx/includes
# Copy error pages
COPY docker/hawtio-?0?.html /usr/share/nginx/html/
# Copy licenses
RUN mkdir -p /opt/hawtio/licenses
COPY --from=builder /hawtio-online/docker/licenses /opt/hawtio/licenses
COPY --from=builder /hawtio-online/packages/online-shell/build /usr/share/nginx/html/online/
COPY --from=envsubst /usr/bin/envsubst /usr/local/bin/
USER 998
CMD ["./nginx.sh"]