Skip to content

NIFI-15138 Fix UndefinedVar warning for the NiFi Docker build#10463

Merged
exceptionfactory merged 1 commit intoapache:mainfrom
peter279k:NIFI-15138
Oct 29, 2025
Merged

NIFI-15138 Fix UndefinedVar warning for the NiFi Docker build#10463
exceptionfactory merged 1 commit intoapache:mainfrom
peter279k:NIFI-15138

Conversation

@peter279k
Copy link
Contributor

Summary

NIFI-15138

Tracking

Please complete the following tracking steps prior to pull request creation.

Issue Tracking

Pull Request Tracking

  • Pull Request title starts with Apache NiFi Jira issue number, such as NIFI-00000
  • Pull Request commit message starts with Apache NiFi Jira issue number, as such NIFI-00000

Pull Request Formatting

  • Pull Request based on current revision of the main branch
  • Pull Request refers to a feature branch with one commit containing changes

Verification

Please indicate the verification steps performed prior to pull request creation.

Build

  • Build completed using ./mvnw clean install -P contrib-check
    • JDK 21
    • JDK 25

Licensing

  • New dependencies are compatible with the Apache License 2.0 according to the License Policy
  • New dependencies are documented in applicable LICENSE and NOTICE files

Documentation

  • Documentation formatting appears as expected in rendered files

@dan-s1 dan-s1 changed the title NIFI-15138 Fix UndefinedVar warning for the NiFi Dokcer build NIFI-15138 Fix UndefinedVar warning for the NiFi Docker build Oct 27, 2025
Copy link
Contributor

@exceptionfactory exceptionfactory left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@peter279k
Copy link
Contributor Author

@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.

@exceptionfactory
Copy link
Contributor

@peter279k Can you share how you are building with this Dockerfile? Removing the value of these arguments, such as MIRROR_BASE_URL causes docker build . to fail. I also did not observe the UndefinedVar warning, can you share where you are seeing that output?

@peter279k
Copy link
Contributor Author

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)

Copy link
Contributor

@exceptionfactory exceptionfactory left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@peter279k
Copy link
Contributor Author

peter279k commented Oct 29, 2025

Here are my commands I run to use this PR with the docker build command:

$ 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.
If having any issue, please notify me. Thanks.

@exceptionfactory
Copy link
Contributor

Thanks for the details steps @peter279k. I'm not following something between these two steps:

$ git checkout NIFI-15138
$ docker build -t apache/nifi:latest .

isn't it necessary to change to the nifi-docker/dockerhub directory? That's where the command is failing when I attempt to run it with the changes.

@peter279k
Copy link
Contributor Author

peter279k commented Oct 29, 2025

Thanks for the details steps @peter279k. I'm not following something between these two steps:

$ git checkout NIFI-15138
$ docker build -t apache/nifi:latest .

isn't it necessary to change to the nifi-docker/dockerhub directory? That's where the command is failing when I attempt to run it with the changes.

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 .

@exceptionfactory
Copy link
Contributor

Thanks for clarifying. Without some other environment variables to populate those ARG values, how are they specified? That's the part that is failing in a local build.

@peter279k
Copy link
Contributor Author

peter279k commented Oct 29, 2025

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 UndefinedVar warning message when building the NiFi Docker image.

The related reference is available here in the official Docker docs.

Copy link
Contributor

@exceptionfactory exceptionfactory left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

@exceptionfactory exceptionfactory merged commit 4b46ce3 into apache:main Oct 29, 2025
8 checks passed
@exceptionfactory exceptionfactory added the hacktoberfest-accepted Hacktoberfest Accepted label Oct 29, 2025
@peter279k
Copy link
Contributor Author

Never mind. Thanks for your reply. And I'm happy to see that you understand this imprvement :).

mark-bathori pushed a commit to mark-bathori/nifi that referenced this pull request Feb 5, 2026
…che#10463)

Signed-off-by: David Handermann <exceptionfactory@apache.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hacktoberfest-accepted Hacktoberfest Accepted

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants