Skip to content

Commit

Permalink
Use Dockerfile 1.4 (#2567)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucacome authored Apr 6, 2022
1 parent 069ca8e commit 95fd169
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 22 deletions.
29 changes: 15 additions & 14 deletions build/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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 #############################################
Expand Down Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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}"
Expand All @@ -263,26 +264,26 @@ 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 #############################################
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 #############################################
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 #############################################
Expand All @@ -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 #############################################
Expand All @@ -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 #############################################
Expand All @@ -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 /
8 changes: 4 additions & 4 deletions tests/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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"]
8 changes: 4 additions & 4 deletions tests/docker/gitlab.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# syntax=docker/dockerfile:1.3
# syntax=docker/dockerfile:1.4
FROM python:3.9

ARG GCLOUD_VERSION=364.0.0
Expand All @@ -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}"

Expand Down

0 comments on commit 95fd169

Please sign in to comment.