NIFI-15138 Fix UndefinedVar warning for the NiFi Docker build#10463
NIFI-15138 Fix UndefinedVar warning for the NiFi Docker build#10463exceptionfactory merged 1 commit intoapache:mainfrom
Conversation
exceptionfactory
left a comment
There was a problem hiding this comment.
Thanks for proposing this correction @peter279k.
How does this change work with setting a default value for the variables changed? As they are not defined above, would this change remove the default value?
|
@exceptionfactory, thanks for reply. This change will not remove the default value and it lets these undefined variables be initialized before using/assigning the default value. This can supress the undefined vairable warning and it can avoid noob Docker users confusing with these warnings when building the NiFi Docker image. |
|
@peter279k Can you share how you are building with this |
|
Thanks for your reply. Here are my completed commands I run to build the NiFi Docker image: $ git clone https://github.com/apache/nifi
$ cd nifi
$ docker version
Client: Docker Engine - Community
Version: 28.5.1
API version: 1.51
Go version: go1.24.8
Git commit: e180ab8
Built: Wed Oct 8 12:17:26 2025
OS/Arch: linux/amd64
Context: default
Server: Docker Engine - Community
Engine:
Version: 28.5.1
API version: 1.51 (minimum version 1.24)
Go version: go1.24.8
Git commit: f8215cc
Built: Wed Oct 8 12:17:26 2025
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: v1.7.28
GitCommit: b98a3aace656320842a23f4a392a33f46af97866
runc:
Version: 1.3.0
GitCommit: v1.3.0-0-g4ca628d1
docker-init:
Version: 0.19.0
GitCommit: de40ad0
$ cd nifi-docker/dockerhub/
$ docker build -t apache/nifi:latest .
[+] Building 164.8s (12/15) docker:default
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 5.09kB 0.0s
=> resolve image config for docker-image://docker.io/docker/dockerfile:1 1.5s
=> CACHED docker-image://docker.io/docker/dockerfile:1@sha256:b6afd42430b15f2d2a4c5a02b919e98a525b785b1a 0.0s
=> [internal] load metadata for docker.io/bellsoft/liberica-openjdk-debian:21 1.1s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 1.04kB 0.0s
=> [internal] load build context 0.0s
=> => transferring context: 21.29kB 0.0s
=> CACHED [1/9] FROM docker.io/bellsoft/liberica-openjdk-debian:21@sha256:6bfd5cd01a5a6933954afb7c7891aa 0.0s
=> [2/9] ADD sh/ /opt/nifi/scripts/ 0.1s
=> [3/9] RUN chmod -R +x /opt/nifi/scripts/*.sh && apt-get update && apt-get install -y unzip 3.3s
=> [4/9] RUN groupadd -g 1000 nifi || groupmod -n nifi `getent group 1000 | cut -d: -f1` && useradd 22.3s
=> [5/9] RUN curl -LsSf https://astral.sh/uv/install.sh | sh 9.5s
=> [6/9] RUN curl -fSL https://archive.apache.org/dist/nifi/2.0.0/nifi-toolkit-2.0.0-bin.zip -o /opt/ni 15.2s
=> [7/9] RUN curl -fSL https://archive.apache.org/dist/nifi/2.0.0/nifi-2.0.0-bin.zip -o /opt/nifi/nifi 111.4s
=> => # % Total % Received % Xferd Average Speed Time Time Time Current
=> => # Dload Upload Total Spent Left Speed
=> => # 42 683M 42 291M 0 0 2685k 0 0:04:20 0:01:50 0:02:30 3066k
......
=> => naming to docker.io/apache/nifi:latest 0.0s
4 warnings found (use docker --debug to expand):
- UndefinedVar: Usage of undefined variable '$MIRROR_BASE_URL' (line 31)
- UndefinedVar: Usage of undefined variable '$DISTRO_PATH' (line 32)
- UndefinedVar: Usage of undefined variable '$NIFI_BINARY_PATH' (line 33)
- UndefinedVar: Usage of undefined variable '$NIFI_TOOLKIT_BINARY_PATH' (line 34) |
exceptionfactory
left a comment
There was a problem hiding this comment.
Thanks for the initial example @peter279k. When removing these default argument values, running docker build . fails. For that reason, it does not seem like this change can go forward. Can you provide an example of this working with the proposed changes?
|
Here are my commands I run to use this PR with the $ docker version
Client: Docker Engine - Community
Version: 28.5.1
API version: 1.51
Go version: go1.24.8
Git commit: e180ab8
Built: Wed Oct 8 12:17:26 2025
OS/Arch: linux/amd64
Context: default
Server: Docker Engine - Community
Engine:
Version: 28.5.1
API version: 1.51 (minimum version 1.24)
Go version: go1.24.8
Git commit: f8215cc
Built: Wed Oct 8 12:17:26 2025
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: v1.7.28
GitCommit: b98a3aace656320842a23f4a392a33f46af97866
runc:
Version: 1.3.0
GitCommit: v1.3.0-0-g4ca628d1
docker-init:
Version: 0.19.0
GitCommit: de40ad0
$ git clone https://github.com/peter279k/nifi
$ git checkout NIFI-15138
$ docker build -t apache/nifi:latest .
[+] Building 280.0s (16/16) FINISHED docker:default
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 5.18kB 0.0s
=> resolve image config for docker-image://docker.io/docker/dockerfile:1 0.3s
=> CACHED docker-image://docker.io/docker/dockerfile:1@sha256:b6afd42430b15f2d2a4c5a02b919e98a525b785b1a 0.0s
=> [internal] load metadata for docker.io/bellsoft/liberica-openjdk-debian:21 0.3s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 1.04kB 0.0s
=> [internal] load build context 0.0s
=> => transferring context: 305B 0.0s
=> CACHED [1/9] FROM docker.io/bellsoft/liberica-openjdk-debian:21@sha256:6bfd5cd01a5a6933954afb7c7891aa 0.0s
=> [2/9] ADD sh/ /opt/nifi/scripts/ 0.1s
=> [3/9] RUN chmod -R +x /opt/nifi/scripts/*.sh && apt-get update && apt-get install -y unzip 3.0s
=> [4/9] RUN groupadd -g 1000 nifi || groupmod -n nifi `getent group 1000 | cut -d: -f1` && useradd 18.6s
=> [5/9] RUN curl -LsSf https://astral.sh/uv/install.sh | sh 6.8s
=> [6/9] RUN curl -fSL https://archive.apache.org/dist/nifi/2.0.0/nifi-toolkit-2.0.0-bin.zip -o /opt/nif 8.9s
=> [7/9] RUN curl -fSL https://archive.apache.org/dist/nifi/2.0.0/nifi-2.0.0-bin.zip -o /opt/nifi/nifi 239.1s
=> [8/9] RUN echo "#!/bin/sh\n" > /opt/nifi/nifi-current/bin/nifi-env.sh 0.3s
=> [9/9] WORKDIR /opt/nifi/nifi-current 0.2s
=> exporting to image 1.9s
=> => exporting layers 1.8s
=> => writing image sha256:29bd47c72686405333cac1e9fb0c55d4445cb12095a4c56c8e469224151072ca 0.0s
=> => naming to docker.io/apache/nifi:latest 0.0s
$According to above of executed command logs, this PR is correct for building NiFi Docker image without confused warnings. |
|
Thanks for the details steps @peter279k. I'm not following something between these two steps: isn't it necessary to change to the |
You're right. I missed these commands: $ git clone https://github.com/peter279k/nifi
$ cd nifi
$ git checkout NIFI-15138
$ cd ./nifi-docker/dockerhub
$ docker build -t apache/nifi:latest . |
|
Thanks for clarifying. Without some other environment variables to populate those |
|
For example, these lines about declaring an argument should be existed at the same time. ARG MIRROR_BASE_URL
ARG MIRROR_BASE_URL=${MIRROR_BASE_URL:-${BASE_URL}}The first line is used to initial this argument, and the second line is used to assign the value to this argument. Once we don't have the first line, it will present the The related reference is available here in the official Docker docs. |
There was a problem hiding this comment.
Thanks for the clarification @peter279k, I misread the change that declares the variable and then assigns it. Thanks for your patience in respone to my questions, this makes sense now!
|
Never mind. Thanks for your reply. And I'm happy to see that you understand this imprvement :). |
…che#10463) Signed-off-by: David Handermann <exceptionfactory@apache.org>
Summary
NIFI-15138
Tracking
Please complete the following tracking steps prior to pull request creation.
Issue Tracking
Pull Request Tracking
NIFI-00000NIFI-00000Pull Request Formatting
mainbranchVerification
Please indicate the verification steps performed prior to pull request creation.
Build
./mvnw clean install -P contrib-checkLicensing
LICENSEandNOTICEfilesDocumentation