File tree Expand file tree Collapse file tree 3 files changed +13
-6
lines changed Expand file tree Collapse file tree 3 files changed +13
-6
lines changed Original file line number Diff line number Diff line change 5050 run : |
5151 docker images | head -n3
5252
53+ - name : Are we running as non-root?
54+ run : |
55+ docker run --rm -t macbre/nginx whoami | grep nginx
56+
5357 - name : Run nginx -V and njs -v
5458 run : |
55- docker run -t macbre/nginx nginx -V | sed 's/\-\-/\n\t--/g' | tee
59+ docker run --rm - t macbre/nginx nginx -V | sed 's/\-\-/\n\t--/g' | tee
5660 echo "njs v$(docker run -t macbre/nginx njs -v)"
5761
5862 - name : Serve a static asset
Original file line number Diff line number Diff line change @@ -218,8 +218,8 @@ COPY --from=base /usr/sbin/njs /usr/sbin/njs
218218
219219# hadolint ignore=SC2046
220220RUN \
221- addgroup -S nginx \
222- && adduser -D -S -h /var/cache/nginx -s /sbin/nologin -G nginx nginx \
221+ addgroup --gid 101 - S nginx \
222+ && adduser --uid 100 - D -S -h /var/cache/nginx -s /sbin/nologin -G nginx nginx \
223223 && apk add --no-cache --virtual .nginx-rundeps tzdata $(cat /tmp/runDeps.txt) \
224224 && rm /tmp/runDeps.txt \
225225 && ln -s /usr/lib/nginx/modules /etc/nginx/modules \
@@ -241,8 +241,13 @@ RUN njs -v
241241# test the configuration
242242RUN nginx -V; nginx -t
243243
244- EXPOSE 80 443
244+ EXPOSE 8080 8443
245245
246246STOPSIGNAL SIGTERM
247247
248+ # prepare to switching to non-root - update file permissions
249+ RUN chown --verbose nginx:nginx \
250+ /var/run/nginx.pid
251+
252+ USER nginx
248253CMD ["nginx" , "-g" , "daemon off;" ]
Original file line number Diff line number Diff line change 55# http://nginx.org/en/docs/ngx_core_module.html#load_module
66include /etc/nginx/main.d/*.conf;
77
8-
9- user nginx;
108worker_processes 1;
119
1210error_log /var/log/nginx/error.log warn;
You can’t perform that action at this time.
0 commit comments