Skip to content

Commit

Permalink
Use ENV variable=xxx instead of ENV variable xxx (#1900)
Browse files Browse the repository at this point in the history
https://docs.docker.com/reference/dockerfile/#env says:

> The ENV instruction also allows an alternative syntax ENV <key> <value>,
> omitting the =.

> This syntax does not allow for multiple environment-variables to be
> set in a single ENV instruction, and can be confusing.

> The alternative syntax is supported for backward compatibility, but
> discouraged for the reasons outlined above, and may be removed in a
> future release.

Recent versions of `docker build` now issue a warning about the use of
the older syntax.  Rather than have warnings displayed in our builds,
let's switch to the newer syntax.

Testing done:

* Successfully ran `make build` and `make test` on my Linux
* Successfully transitioned my personal container definitions to new syntax without issue
  • Loading branch information
MarkEWaite committed Jun 25, 2024
1 parent 4ffcdd6 commit 217e7c7
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 57 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,15 @@ FROM jenkins/jenkins:lts-jdk17
COPY --chown=jenkins:jenkins certificate.pfx /var/lib/jenkins/certificate.pfx
COPY --chown=jenkins:jenkins https.key /var/lib/jenkins/pk
ENV JENKINS_OPTS --httpPort=-1 --httpsPort=8083 --httpsKeyStore=/var/lib/jenkins/certificate.pfx --httpsKeyStorePassword=Password12
ENV JENKINS_OPTS="--httpPort=-1 --httpsPort=8083 --httpsKeyStore=/var/lib/jenkins/certificate.pfx --httpsKeyStorePassword=Password12"
EXPOSE 8083
```

You can also change the default agent port for Jenkins by defining `JENKINS_SLAVE_AGENT_PORT` in a sample Dockerfile.

```
FROM jenkins/jenkins:lts-jdk17
ENV JENKINS_SLAVE_AGENT_PORT 50001
ENV JENKINS_SLAVE_AGENT_PORT=50001
```

or as a parameter to docker,
Expand Down
16 changes: 8 additions & 8 deletions almalinux/almalinux8/hotspot/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ RUN jlink \

FROM almalinux:8.10 AS controller

ENV LANG C.UTF-8
ENV LANG=C.UTF-8

ARG TARGETARCH
ARG COMMIT_SHA
Expand All @@ -52,9 +52,9 @@ ARG agent_port=50000
ARG JENKINS_HOME=/var/jenkins_home
ARG REF=/usr/share/jenkins/ref

ENV JENKINS_HOME $JENKINS_HOME
ENV JENKINS_SLAVE_AGENT_PORT ${agent_port}
ENV REF $REF
ENV JENKINS_HOME=$JENKINS_HOME
ENV JENKINS_SLAVE_AGENT_PORT=${agent_port}
ENV REF=$REF

# Jenkins is run with user `jenkins`, uid = 1000
# If you bind mount a volume from the host or a data container,
Expand Down Expand Up @@ -85,7 +85,7 @@ RUN curl -fsSL "https://github.com/krallin/tini/releases/download/${TINI_VERSION

# jenkins version being bundled in this docker image
ARG JENKINS_VERSION
ENV JENKINS_VERSION ${JENKINS_VERSION:-2.442}
ENV JENKINS_VERSION=${JENKINS_VERSION:-2.442}

# jenkins.war checksum, download will be validated using it
ARG JENKINS_SHA=b4f596923eb37b93c3f5a21a6a32fc3bedd57d04a1b63186811c0ce8b3d9f07c
Expand All @@ -100,7 +100,7 @@ RUN curl -fsSL ${JENKINS_URL} -o /usr/share/jenkins/jenkins.war \
&& sha256sum -c --strict /tmp/jenkins_sha \
&& rm -f /tmp/jenkins_sha

ENV JENKINS_UC https://updates.jenkins.io
ENV JENKINS_UC=https://updates.jenkins.io
ENV JENKINS_UC_EXPERIMENTAL=https://updates.jenkins.io/experimental
ENV JENKINS_INCREMENTALS_REPO_MIRROR=https://repo.jenkins-ci.org/incrementals
RUN chown -R ${user} "$JENKINS_HOME" "$REF"
Expand All @@ -118,10 +118,10 @@ EXPOSE ${http_port}
# will be used by attached agents:
EXPOSE ${agent_port}

ENV COPY_REFERENCE_FILE_LOG $JENKINS_HOME/copy_reference_file.log
ENV COPY_REFERENCE_FILE_LOG=$JENKINS_HOME/copy_reference_file.log

ENV JAVA_HOME=/opt/java/openjdk
ENV PATH "${JAVA_HOME}/bin:${PATH}"
ENV PATH="${JAVA_HOME}/bin:${PATH}"
COPY --from=jre-build /javaruntime $JAVA_HOME

USER ${user}
Expand Down
16 changes: 8 additions & 8 deletions alpine/hotspot/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ RUN apk add --no-cache \
unzip \
&& git lfs install

ENV LANG C.UTF-8
ENV LANG=C.UTF-8

ARG TARGETARCH
ARG COMMIT_SHA
Expand All @@ -69,9 +69,9 @@ ARG agent_port=50000
ARG JENKINS_HOME=/var/jenkins_home
ARG REF=/usr/share/jenkins/ref

ENV JENKINS_HOME $JENKINS_HOME
ENV JENKINS_SLAVE_AGENT_PORT ${agent_port}
ENV REF $REF
ENV JENKINS_HOME=$JENKINS_HOME
ENV JENKINS_SLAVE_AGENT_PORT=${agent_port}
ENV REF=$REF

# Jenkins is run with user `jenkins`, uid = 1000
# If you bind mount a volume from the host or a data container,
Expand All @@ -92,7 +92,7 @@ RUN mkdir -p ${REF}/init.groovy.d

# jenkins version being bundled in this docker image
ARG JENKINS_VERSION
ENV JENKINS_VERSION ${JENKINS_VERSION:-2.442}
ENV JENKINS_VERSION=${JENKINS_VERSION:-2.442}

# jenkins.war checksum, download will be validated using it
ARG JENKINS_SHA=b4f596923eb37b93c3f5a21a6a32fc3bedd57d04a1b63186811c0ce8b3d9f07c
Expand All @@ -107,7 +107,7 @@ RUN curl -fsSL ${JENKINS_URL} -o /usr/share/jenkins/jenkins.war \
&& sha256sum -c --strict /tmp/jenkins_sha \
&& rm -f /tmp/jenkins_sha

ENV JENKINS_UC https://updates.jenkins.io
ENV JENKINS_UC=https://updates.jenkins.io
ENV JENKINS_UC_EXPERIMENTAL=https://updates.jenkins.io/experimental
ENV JENKINS_INCREMENTALS_REPO_MIRROR=https://repo.jenkins-ci.org/incrementals
RUN chown -R ${user} "$JENKINS_HOME" "$REF"
Expand All @@ -125,10 +125,10 @@ EXPOSE ${http_port}
# will be used by attached agents:
EXPOSE ${agent_port}

ENV COPY_REFERENCE_FILE_LOG $JENKINS_HOME/copy_reference_file.log
ENV COPY_REFERENCE_FILE_LOG=$JENKINS_HOME/copy_reference_file.log

ENV JAVA_HOME=/opt/java/openjdk
ENV PATH "${JAVA_HOME}/bin:${PATH}"
ENV PATH="${JAVA_HOME}/bin:${PATH}"
COPY --from=jre-build /javaruntime $JAVA_HOME

USER ${user}
Expand Down
16 changes: 8 additions & 8 deletions debian/bookworm-slim/hotspot/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ RUN curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.d
&& rm -rf /var/lib/apt/lists/* \
&& git lfs install

ENV LANG C.UTF-8
ENV LANG=C.UTF-8

ARG TARGETARCH
ARG COMMIT_SHA
Expand All @@ -78,9 +78,9 @@ ARG agent_port=50000
ARG JENKINS_HOME=/var/jenkins_home
ARG REF=/usr/share/jenkins/ref

ENV JENKINS_HOME $JENKINS_HOME
ENV JENKINS_SLAVE_AGENT_PORT ${agent_port}
ENV REF $REF
ENV JENKINS_HOME=$JENKINS_HOME
ENV JENKINS_SLAVE_AGENT_PORT=${agent_port}
ENV REF=$REF

# Jenkins is run with user `jenkins`, uid = 1000
# If you bind mount a volume from the host or a data container,
Expand All @@ -101,7 +101,7 @@ RUN mkdir -p ${REF}/init.groovy.d

# jenkins version being bundled in this docker image
ARG JENKINS_VERSION
ENV JENKINS_VERSION ${JENKINS_VERSION:-2.442}
ENV JENKINS_VERSION=${JENKINS_VERSION:-2.442}

# jenkins.war checksum, download will be validated using it
ARG JENKINS_SHA=b4f596923eb37b93c3f5a21a6a32fc3bedd57d04a1b63186811c0ce8b3d9f07c
Expand All @@ -116,7 +116,7 @@ RUN curl -fsSL ${JENKINS_URL} -o /usr/share/jenkins/jenkins.war \
&& sha256sum -c --strict /tmp/jenkins_sha \
&& rm -f /tmp/jenkins_sha

ENV JENKINS_UC https://updates.jenkins.io
ENV JENKINS_UC=https://updates.jenkins.io
ENV JENKINS_UC_EXPERIMENTAL=https://updates.jenkins.io/experimental
ENV JENKINS_INCREMENTALS_REPO_MIRROR=https://repo.jenkins-ci.org/incrementals
RUN chown -R ${user} "$JENKINS_HOME" "$REF"
Expand All @@ -134,10 +134,10 @@ EXPOSE ${http_port}
# will be used by attached agents:
EXPOSE ${agent_port}

ENV COPY_REFERENCE_FILE_LOG $JENKINS_HOME/copy_reference_file.log
ENV COPY_REFERENCE_FILE_LOG=$JENKINS_HOME/copy_reference_file.log

ENV JAVA_HOME=/opt/java/openjdk
ENV PATH "${JAVA_HOME}/bin:${PATH}"
ENV PATH="${JAVA_HOME}/bin:${PATH}"
COPY --from=jre-build /javaruntime $JAVA_HOME

USER ${user}
Expand Down
16 changes: 8 additions & 8 deletions debian/bookworm/hotspot/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ RUN curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.d
&& rm -rf /var/lib/apt/lists/* \
&& git lfs install

ENV LANG C.UTF-8
ENV LANG=C.UTF-8

ARG TARGETARCH
ARG COMMIT_SHA
Expand All @@ -78,9 +78,9 @@ ARG agent_port=50000
ARG JENKINS_HOME=/var/jenkins_home
ARG REF=/usr/share/jenkins/ref

ENV JENKINS_HOME $JENKINS_HOME
ENV JENKINS_SLAVE_AGENT_PORT ${agent_port}
ENV REF $REF
ENV JENKINS_HOME=$JENKINS_HOME
ENV JENKINS_SLAVE_AGENT_PORT=${agent_port}
ENV REF=$REF

# Jenkins is run with user `jenkins`, uid = 1000
# If you bind mount a volume from the host or a data container,
Expand All @@ -101,7 +101,7 @@ RUN mkdir -p ${REF}/init.groovy.d

# jenkins version being bundled in this docker image
ARG JENKINS_VERSION
ENV JENKINS_VERSION ${JENKINS_VERSION:-2.442}
ENV JENKINS_VERSION=${JENKINS_VERSION:-2.442}

# jenkins.war checksum, download will be validated using it
ARG JENKINS_SHA=b4f596923eb37b93c3f5a21a6a32fc3bedd57d04a1b63186811c0ce8b3d9f07c
Expand All @@ -116,7 +116,7 @@ RUN curl -fsSL ${JENKINS_URL} -o /usr/share/jenkins/jenkins.war \
&& sha256sum -c --strict /tmp/jenkins_sha \
&& rm -f /tmp/jenkins_sha

ENV JENKINS_UC https://updates.jenkins.io
ENV JENKINS_UC=https://updates.jenkins.io
ENV JENKINS_UC_EXPERIMENTAL=https://updates.jenkins.io/experimental
ENV JENKINS_INCREMENTALS_REPO_MIRROR=https://repo.jenkins-ci.org/incrementals
RUN chown -R ${user} "$JENKINS_HOME" "$REF"
Expand All @@ -134,10 +134,10 @@ EXPOSE ${http_port}
# will be used by attached agents:
EXPOSE ${agent_port}

ENV COPY_REFERENCE_FILE_LOG $JENKINS_HOME/copy_reference_file.log
ENV COPY_REFERENCE_FILE_LOG=$JENKINS_HOME/copy_reference_file.log

ENV JAVA_HOME=/opt/java/openjdk
ENV PATH "${JAVA_HOME}/bin:${PATH}"
ENV PATH="${JAVA_HOME}/bin:${PATH}"
COPY --from=jre-build /javaruntime $JAVA_HOME

USER ${user}
Expand Down
16 changes: 8 additions & 8 deletions rhel/ubi8/hotspot/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ RUN jlink \

FROM registry.access.redhat.com/ubi8/ubi:8.10-901.1717584420 AS controller

ENV LANG C.UTF-8
ENV LANG=C.UTF-8

ARG TARGETARCH
ARG COMMIT_SHA
Expand All @@ -55,9 +55,9 @@ ARG agent_port=50000
ARG JENKINS_HOME=/var/jenkins_home
ARG REF=/usr/share/jenkins/ref

ENV JENKINS_HOME $JENKINS_HOME
ENV JENKINS_SLAVE_AGENT_PORT ${agent_port}
ENV REF $REF
ENV JENKINS_HOME=$JENKINS_HOME
ENV JENKINS_SLAVE_AGENT_PORT=${agent_port}
ENV REF=$REF

# Jenkins is run with user `jenkins`, uid = 1000
# If you bind mount a volume from the host or a data container,
Expand Down Expand Up @@ -88,7 +88,7 @@ RUN curl -fsSL "https://github.com/krallin/tini/releases/download/${TINI_VERSION

# jenkins version being bundled in this docker image
ARG JENKINS_VERSION
ENV JENKINS_VERSION ${JENKINS_VERSION:-2.442}
ENV JENKINS_VERSION=${JENKINS_VERSION:-2.442}

# jenkins.war checksum, download will be validated using it
ARG JENKINS_SHA=b4f596923eb37b93c3f5a21a6a32fc3bedd57d04a1b63186811c0ce8b3d9f07c
Expand All @@ -103,7 +103,7 @@ RUN curl -fsSL ${JENKINS_URL} -o /usr/share/jenkins/jenkins.war \
&& sha256sum -c --strict /tmp/jenkins_sha \
&& rm -f /tmp/jenkins_sha

ENV JENKINS_UC https://updates.jenkins.io
ENV JENKINS_UC=ttps://updates.jenkins.io
ENV JENKINS_UC_EXPERIMENTAL=https://updates.jenkins.io/experimental
ENV JENKINS_INCREMENTALS_REPO_MIRROR=https://repo.jenkins-ci.org/incrementals
RUN chown -R ${user} "$JENKINS_HOME" "$REF"
Expand All @@ -121,10 +121,10 @@ EXPOSE ${http_port}
# will be used by attached agents:
EXPOSE ${agent_port}

ENV COPY_REFERENCE_FILE_LOG $JENKINS_HOME/copy_reference_file.log
ENV COPY_REFERENCE_FILE_LOG=$JENKINS_HOME/copy_reference_file.log

ENV JAVA_HOME=/opt/java/openjdk
ENV PATH "${JAVA_HOME}/bin:${PATH}"
ENV PATH="${JAVA_HOME}/bin:${PATH}"
COPY --from=jre-build /javaruntime $JAVA_HOME

USER ${user}
Expand Down
16 changes: 8 additions & 8 deletions rhel/ubi9/hotspot/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ RUN case "$(jlink --version 2>&1)" in \

FROM registry.access.redhat.com/ubi9/ubi:9.4-1123 AS controller

ENV LANG C.UTF-8
ENV LANG=C.UTF-8

ARG TARGETARCH
ARG COMMIT_SHA
Expand All @@ -61,9 +61,9 @@ ARG agent_port=50000
ARG JENKINS_HOME=/var/jenkins_home
ARG REF=/usr/share/jenkins/ref

ENV JENKINS_HOME $JENKINS_HOME
ENV JENKINS_SLAVE_AGENT_PORT ${agent_port}
ENV REF $REF
ENV JENKINS_HOME=$JENKINS_HOME
ENV JENKINS_SLAVE_AGENT_PORT=${agent_port}
ENV REF=$REF

# Jenkins is run with user `jenkins`, uid = 1000
# If you bind mount a volume from the host or a data container,
Expand Down Expand Up @@ -94,7 +94,7 @@ RUN curl -fsSL "https://github.com/krallin/tini/releases/download/${TINI_VERSION

# jenkins version being bundled in this docker image
ARG JENKINS_VERSION
ENV JENKINS_VERSION ${JENKINS_VERSION:-2.442}
ENV JENKINS_VERSION=${JENKINS_VERSION:-2.442}

# jenkins.war checksum, download will be validated using it
ARG JENKINS_SHA=b4f596923eb37b93c3f5a21a6a32fc3bedd57d04a1b63186811c0ce8b3d9f07c
Expand All @@ -109,7 +109,7 @@ RUN curl -fsSL ${JENKINS_URL} -o /usr/share/jenkins/jenkins.war \
&& sha256sum -c --strict /tmp/jenkins_sha \
&& rm -f /tmp/jenkins_sha

ENV JENKINS_UC https://updates.jenkins.io
ENV JENKINS_UC=https://updates.jenkins.io
ENV JENKINS_UC_EXPERIMENTAL=https://updates.jenkins.io/experimental
ENV JENKINS_INCREMENTALS_REPO_MIRROR=https://repo.jenkins-ci.org/incrementals
RUN chown -R ${user} "$JENKINS_HOME" "$REF"
Expand All @@ -127,10 +127,10 @@ EXPOSE ${http_port}
# will be used by attached agents:
EXPOSE ${agent_port}

ENV COPY_REFERENCE_FILE_LOG $JENKINS_HOME/copy_reference_file.log
ENV COPY_REFERENCE_FILE_LOG=$JENKINS_HOME/copy_reference_file.log

ENV JAVA_HOME=/opt/java/openjdk
ENV PATH "${JAVA_HOME}/bin:${PATH}"
ENV PATH="${JAVA_HOME}/bin:${PATH}"
COPY --from=jre-build /javaruntime $JAVA_HOME

USER ${user}
Expand Down
2 changes: 1 addition & 1 deletion tests/plugins-cli/custom-war/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM bats-jenkins

# Define a custom location for the war
ENV JENKINS_WAR /test-custom-dockerfile/my-custom-jenkins.war
ENV JENKINS_WAR=/test-custom-dockerfile/my-custom-jenkins.war
WORKDIR /test-custom-dockerfile
# Add there a new weird plugin to assert
COPY --chown=jenkins:jenkins WEB-INF/ WEB-INF/
Expand Down
2 changes: 1 addition & 1 deletion tests/plugins-cli/custom-war/Dockerfile-windows
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM bats-jenkins
# hadolint shell=powershell

# Define a custom location for the war
ENV JENKINS_WAR C:/ProgramData/TestCustomDockerfile/my-custom-jenkins.war
ENV JENKINS_WAR=C:/ProgramData/TestCustomDockerfile/my-custom-jenkins.war
WORKDIR C:/ProgramData/TestCustomDockerfile
# Add there a new weird plugin to assert
COPY WEB-INF/ WEB-INF/
Expand Down
10 changes: 5 additions & 5 deletions windows/windowsservercore/hotspot/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ ARG JENKINS_HOME=C:/ProgramData/Jenkins/JenkinsHome

ARG COMMIT_SHA

ENV JENKINS_HOME $JENKINS_HOME
ENV JENKINS_AGENT_PORT ${agent_port}
ENV JENKINS_HOME=$JENKINS_HOME
ENV JENKINS_AGENT_PORT=${agent_port}

# Jenkins home directory is a volume, so configuration and build history
# can be persisted and survive image upgrades
Expand Down Expand Up @@ -97,7 +97,7 @@ RUN New-Item -ItemType Directory -Force -Path C:/ProgramData/Jenkins/Reference/i

# jenkins version being bundled in this docker image
ARG JENKINS_VERSION
ENV JENKINS_VERSION ${JENKINS_VERSION:-2.442}
ENV JENKINS_VERSION=${JENKINS_VERSION:-2.442}

# jenkins.war checksum, download will be validated using it
ARG JENKINS_SHA=b4f596923eb37b93c3f5a21a6a32fc3bedd57d04a1b63186811c0ce8b3d9f07c
Expand All @@ -110,7 +110,7 @@ ARG JENKINS_URL=https://repo.jenkins-ci.org/public/org/jenkins-ci/main/jenkins-w
RUN Invoke-WebRequest -Uri "$env:JENKINS_URL" -OutFile C:/ProgramData/Jenkins/jenkins.war ; `
if ((Get-FileHash C:/ProgramData/Jenkins/jenkins.war -Algorithm SHA256).Hash -ne $env:JENKINS_SHA) {exit 1}

ENV JENKINS_UC https://updates.jenkins.io
ENV JENKINS_UC=https://updates.jenkins.io
ENV JENKINS_UC_EXPERIMENTAL=https://updates.jenkins.io/experimental
ENV JENKINS_INCREMENTALS_REPO_MIRROR=https://repo.jenkins-ci.org/incrementals

Expand All @@ -126,7 +126,7 @@ EXPOSE ${http_port}
# will be used by attached agents:
EXPOSE ${agent_port}

ENV COPY_REFERENCE_FILE_LOG $JENKINS_HOME/copy_reference_file.log
ENV COPY_REFERENCE_FILE_LOG=$JENKINS_HOME/copy_reference_file.log

COPY jenkins-support.psm1 C:/ProgramData/Jenkins
COPY jenkins.ps1 C:/ProgramData/Jenkins
Expand Down

0 comments on commit 217e7c7

Please sign in to comment.