diff --git a/build/Dockerfile b/build/Dockerfile index feddc5aa51..ccdf781d8c 100644 --- a/build/Dockerfile +++ b/build/Dockerfile @@ -1,4 +1,4 @@ -# syntax=docker/dockerfile:1.3 +# syntax=docker/dockerfile:1.4 ARG BUILD_OS=debian ARG NGINX_PLUS_VERSION=r26 ARG DOWNLOAD_TAG=edge @@ -114,7 +114,7 @@ RUN dnf --nodocs install -y shadow-utils ca-certificates \ && groupadd --system --gid 101 nginx \ && useradd --system --gid nginx --no-create-home --home-dir /nonexistent --comment "nginx user" --shell /bin/false --uid 101 nginx -COPY --chown=nginx:0 LICENSE /licenses/ +COPY --link --chown=101:0 LICENSE /licenses/ ############################################# Base image for UBI OSS ############################################# @@ -221,7 +221,7 @@ RUN --mount=target=/tmp [ -n "${BUILD_OS##*plus*}" ] && exit 0; mkdir -p etc/ngi # run only on nap waf build RUN --mount=target=/tmp [ -n "${NAP_MODULES##*waf*}" ] && exit 0; mkdir -p /etc/nginx/waf/nac-policies /etc/nginx/waf/nac-logconfs /etc/nginx/waf/nac-usersigs /var/log/app_protect /opt/app_protect \ - && chown -R nginx:0 /etc/app_protect /usr/share/ts /var/log/app_protect/ /opt/app_protect/ /var/log/nginx/ \ + && chown -R 101:0 /etc/app_protect /usr/share/ts /var/log/app_protect/ /opt/app_protect/ /var/log/nginx/ \ && touch /etc/nginx/waf/nac-usersigs/index.conf \ && cp -a /tmp/build/log-default.json /etc/nginx @@ -234,7 +234,7 @@ RUN --mount=target=/tmp mkdir -p /var/lib/nginx /etc/nginx/secrets /etc/nginx/st && setcap -v 'cap_net_bind_service=+ep' /usr/sbin/nginx 'cap_net_bind_service=+ep' /usr/sbin/nginx-debug \ && [ -z "${BUILD_OS##*plus*}" ] && PLUS=-plus; cp -a /tmp/internal/configs/version1/nginx$PLUS.ingress.tmpl /tmp/internal/configs/version1/nginx$PLUS.tmpl \ /tmp/internal/configs/version2/nginx$PLUS.virtualserver.tmpl /tmp/internal/configs/version2/nginx$PLUS.transportserver.tmpl / \ - && chown -R nginx:0 /etc/nginx /etc/nginx/secrets /var/cache/nginx /var/lib/nginx /*.tmpl \ + && chown -R 101:0 /etc/nginx /etc/nginx/secrets /var/cache/nginx /var/lib/nginx /*.tmpl \ && rm -f /etc/nginx/conf.d/* /etc/apt/apt.conf.d/90pkgs-nginx /etc/apt/sources.list.d/nginx-plus.list # Uncomment the line below if you would like to add the default.pem to the image @@ -245,7 +245,8 @@ EXPOSE 80 443 STOPSIGNAL SIGTERM ENTRYPOINT ["/nginx-ingress"] -USER nginx +# 101 is nginx +USER 101 LABEL org.opencontainers.image.version="${IC_VERSION}" LABEL org.opencontainers.image.revision="${GIT_COMMIT}" @@ -263,10 +264,10 @@ ARG DATE ARG TARGETARCH WORKDIR /go/src/github.com/nginxinc/kubernetes-ingress/nginx-ingress/cmd/nginx-ingress -COPY go.mod go.sum /go/src/github.com/nginxinc/kubernetes-ingress/nginx-ingress/ -RUN go mod download -COPY . /go/src/github.com/nginxinc/kubernetes-ingress/nginx-ingress/ -RUN CGO_ENABLED=0 GO111MODULE=on GOOS=linux GOARCH=$TARGETARCH go build -trimpath -ldflags "-s -w -X main.version=${IC_VERSION} -X main.commit=${GIT_COMMIT} -X main.date=${DATE}" -o /nginx-ingress +RUN --mount=target=/go/src/github.com/nginxinc/kubernetes-ingress/nginx-ingress/ --mount=type=cache,target=/root/.cache/go-build \ + go mod download +RUN --mount=target=/go/src/github.com/nginxinc/kubernetes-ingress/nginx-ingress/ --mount=type=cache,target=/root/.cache/go-build \ + CGO_ENABLED=0 GO111MODULE=on GOOS=linux GOARCH=$TARGETARCH go build -trimpath -ldflags "-s -w -X main.version=${IC_VERSION} -X main.commit=${GIT_COMMIT} -X main.date=${DATE}" -o /nginx-ingress ############################################# Create image with nginx-ingress built in container ############################################# @@ -274,7 +275,7 @@ FROM common AS container LABEL org.nginx.kic.image.build.version="container" -COPY --chown=nginx:0 --from=builder /nginx-ingress / +COPY --link --from=builder --chown=101:0 /nginx-ingress / ############################################# Create image with nginx-ingress built locally ############################################# @@ -282,7 +283,7 @@ FROM common AS local LABEL org.nginx.kic.image.build.version="local" -COPY --chown=nginx:0 ./nginx-ingress / +COPY --link --chown=101:0 nginx-ingress / ############################################# Create image with nginx-ingress built by GoReleaser ############################################# @@ -292,7 +293,7 @@ ARG TARGETVARIANT LABEL org.nginx.kic.image.build.version="goreleaser" -COPY --chown=nginx:0 ./dist/kubernetes-ingress_linux_$TARGETARCH${TARGETVARIANT:+_7}/nginx-ingress / +COPY --link --chown=101:0 dist/kubernetes-ingress_linux_$TARGETARCH${TARGETVARIANT:+_7}/nginx-ingress / ############################################# Create image with nginx-ingress built by GoReleaser for AWS Marketplace ############################################# @@ -301,7 +302,7 @@ ARG TARGETARCH LABEL org.nginx.kic.image.build.version="aws" -COPY --chown=nginx:0 ./dist/aws_linux_$TARGETARCH/nginx-ingress / +COPY --link --chown=101:0 dist/aws_linux_$TARGETARCH/nginx-ingress / ############################################# Create image with nginx-ingress extracted from image on Docker Hub ############################################# @@ -311,4 +312,4 @@ FROM common as download LABEL org.nginx.kic.image.build.version="binaries" -COPY --from=kic /nginx-ingress / +COPY --link --from=kic --chown=101:0 /nginx-ingress / diff --git a/tests/docker/Dockerfile b/tests/docker/Dockerfile index eb83fb9308..f123431802 100644 --- a/tests/docker/Dockerfile +++ b/tests/docker/Dockerfile @@ -1,4 +1,4 @@ -# syntax=docker/dockerfile:1.3 +# syntax=docker/dockerfile:1.4 # this is here so we can grab the latest version of kind and have dependabot keep it up to date FROM kindest/node:v1.23.5 @@ -10,15 +10,15 @@ RUN apt-get update \ WORKDIR /workspace/tests -COPY tests/requirements.txt /workspace/tests/ +COPY --link tests/requirements.txt /workspace/tests/ RUN pip install -r requirements.txt -COPY deployments /workspace/deployments +COPY --link deployments /workspace/deployments RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl \ && install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl \ && apt-get update && apt-get install -y apache2-utils -COPY tests /workspace/tests +COPY --link tests /workspace/tests ENTRYPOINT ["python3", "-m", "pytest"] diff --git a/tests/docker/gitlab.Dockerfile b/tests/docker/gitlab.Dockerfile index 79a110f5d7..b6da0fecea 100644 --- a/tests/docker/gitlab.Dockerfile +++ b/tests/docker/gitlab.Dockerfile @@ -1,4 +1,4 @@ -# syntax=docker/dockerfile:1.3 +# syntax=docker/dockerfile:1.4 FROM python:3.9 ARG GCLOUD_VERSION=364.0.0 @@ -17,11 +17,11 @@ RUN apt-get update && apt-get install -y curl git jq apache2-utils \ WORKDIR /workspace/tests -COPY tests/requirements.txt /workspace/tests/ +COPY --link tests/requirements.txt /workspace/tests/ RUN pip install -r requirements.txt -COPY tests /workspace/tests -COPY deployments /workspace/deployments +COPY --link tests /workspace/tests +COPY --link deployments /workspace/deployments ENV PATH="/usr/lib/google-cloud-sdk/bin:${PATH}"