Skip to content

Commit

Permalink
Merge pull request macbre#123 from victor-sm/master
Browse files Browse the repository at this point in the history
Added uid and gid ARG for nginx user
  • Loading branch information
macbre authored Oct 18, 2023
2 parents 4b68655 + ac0aee3 commit 8f14b0f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ ARG HEADERS_MORE_VERSION=0.34
# https://github.com/leev/ngx_http_geoip2_module/releases
ARG GEOIP2_VERSION=3.4

# NGINX UID / GID
ARG NGINX_USER_UID=100
ARG NGINX_GROUP_GID=101

# https://nginx.org/en/docs/http/ngx_http_v3_module.html
ARG CONFIG="\
--build=quic-$NGINX_COMMIT-boringssl-$BORINGSSL_COMMIT \
Expand Down Expand Up @@ -82,6 +86,8 @@ ARG NGX_BROTLI_COMMIT
ARG HEADERS_MORE_VERSION
ARG NJS_COMMIT
ARG GEOIP2_VERSION
ARG NGINX_USER_UID
ARG NGINX_GROUP_GID
ARG CONFIG

RUN \
Expand Down Expand Up @@ -202,6 +208,8 @@ RUN \
FROM alpine:3.17
ARG NGINX_VERSION
ARG NGINX_COMMIT
ARG NGINX_USER_UID
ARG NGINX_GROUP_GID

ENV NGINX_VERSION $NGINX_VERSION
ENV NGINX_COMMIT $NGINX_COMMIT
Expand All @@ -218,8 +226,8 @@ COPY --from=base /usr/sbin/njs /usr/sbin/njs

# hadolint ignore=SC2046
RUN \
addgroup --gid 101 -S nginx \
&& adduser --uid 100 -D -S -h /var/cache/nginx -s /sbin/nologin -G nginx nginx \
addgroup --gid $NGINX_GROUP_GID -S nginx \
&& adduser --uid $NGINX_USER_UID -D -S -h /var/cache/nginx -s /sbin/nologin -G nginx nginx \
&& apk add --no-cache --virtual .nginx-rundeps tzdata $(cat /tmp/runDeps.txt) \
&& rm /tmp/runDeps.txt \
&& ln -s /usr/lib/nginx/modules /etc/nginx/modules \
Expand Down

0 comments on commit 8f14b0f

Please sign in to comment.