NIFI-11351 Support Docker image builds on ARM64

- Switch from spotify docker-maven-plugin to fabric8 docker-maven-plugin
- Add consistency to docker maven image names and tags
- Other minor Dockerfile changes for consistency

This closes #7105

Signed-off-by: David Handermann <exceptionfactory@apache.org>
This commit is contained in:
Kevin Doran 2023-03-28 12:47:59 -04:00 committed by exceptionfactory
parent f61d547e3e
commit 08e18220e7
No known key found for this signature in database
GPG Key ID: 29B6A52D2AAE8DBA
10 changed files with 155 additions and 101 deletions

View File

@ -60,21 +60,35 @@ limitations under the License.
</executions>
</plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<executions>
<execution>
<id>build-docker-image</id>
<phase>install</phase>
<goals>
<goal>build</goal>
</goals>
<configuration>
<dockerfile>dockermaven/Dockerfile</dockerfile>
<buildArgs>
<UID>1000</UID>
<GID>1000</GID>
<MINIFI_C2_VERSION>${minifi.c2.version}</MINIFI_C2_VERSION>
<MINIFI_C2_BINARY_NAME>minifi-c2-${minifi.c2.version}-bin.zip</MINIFI_C2_BINARY_NAME>
<MINIFI_C2_BINARY>target/minifi-c2-${minifi.c2.version}-bin.zip</MINIFI_C2_BINARY>
</buildArgs>
<repository>apacheminific2</repository>
<tag>${minifi.c2.version}</tag>
<images>
<image>
<name>apache/nifi-minifi-c2</name>
<build>
<tags>
<tag>${minifi.c2.version}-maven</tag>
</tags>
<dockerFile>dockermaven/Dockerfile</dockerFile>
<contextDir>${project.basedir}</contextDir>
<args>
<UID>1000</UID>
<GID>1000</GID>
<MINIFI_C2_VERSION>${minifi.c2.version}</MINIFI_C2_VERSION>
<MINIFI_C2_BINARY_NAME>minifi-c2-${minifi.c2.version}-bin.zip</MINIFI_C2_BINARY_NAME>
<MINIFI_C2_BINARY>target/minifi-c2-${minifi.c2.version}-bin.zip</MINIFI_C2_BINARY>
</args>
</build>
</image>
</images>
</configuration>
</execution>
</executions>

View File

@ -77,24 +77,38 @@ limitations under the License.
</executions>
</plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<executions>
<execution>
<id>build-docker-image</id>
<phase>install</phase>
<goals>
<goal>build</goal>
</goals>
<configuration>
<dockerfile>dockermaven/Dockerfile</dockerfile>
<buildArgs>
<IMAGE_NAME>${docker.image.name}</IMAGE_NAME>
<IMAGE_TAG>${docker.image.tag}</IMAGE_TAG>
<UID>1000</UID>
<GID>1000</GID>
<MINIFI_VERSION>${minifi.version}</MINIFI_VERSION>
<MINIFI_BINARY_NAME>minifi-${minifi.version}-bin.zip</MINIFI_BINARY_NAME>
<MINIFI_BINARY>target/minifi-${minifi.version}-bin.zip</MINIFI_BINARY>
<MINIFI_SCRIPTS>target/sh</MINIFI_SCRIPTS>
</buildArgs>
<repository>apacheminifi</repository>
<tag>${minifi.version}</tag>
<images>
<image>
<name>apache/nifi-minifi</name>
<build>
<tags>
<tag>${minifi.version}-maven</tag>
</tags>
<dockerFile>dockermaven/Dockerfile</dockerFile>
<contextDir>${project.basedir}</contextDir>
<args>
<IMAGE_NAME>${docker.image.name}</IMAGE_NAME>
<IMAGE_TAG>${docker.image.tag}</IMAGE_TAG>
<UID>1000</UID>
<GID>1000</GID>
<MINIFI_VERSION>${minifi.version}</MINIFI_VERSION>
<MINIFI_BINARY_NAME>minifi-${minifi.version}-bin.zip</MINIFI_BINARY_NAME>
<MINIFI_BINARY>target/minifi-${minifi.version}-bin.zip</MINIFI_BINARY>
<MINIFI_SCRIPTS>target/sh</MINIFI_SCRIPTS>
</args>
</build>
</image>
</images>
</configuration>
</execution>
</executions>

View File

@ -33,28 +33,38 @@
<build>
<plugins>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<executions>
<execution>
<id>default</id>
<id>build-docker-image</id>
<phase>package</phase>
<goals>
<goal>build</goal>
</goals>
<configuration>
<buildArgs>
<IMAGE_NAME>${docker.image.name}</IMAGE_NAME>
<IMAGE_TAG>${docker.image.tag}</IMAGE_TAG>
<MAINTAINER>${docker.maintainer}</MAINTAINER>
<UID>1000</UID>
<GID>1000</GID>
<NIFI_VERSION>${project.version}</NIFI_VERSION>
<NIFI_BINARY>target/nifi-${nifi.version}-bin.zip</NIFI_BINARY>
<NIFI_TOOLKIT_BINARY>target/nifi-toolkit-${nifi.version}-bin.zip</NIFI_TOOLKIT_BINARY>
<NIFI_SCRIPTS>target/sh</NIFI_SCRIPTS>
</buildArgs>
<repository>apache/nifi</repository>
<tag>${project.version}-dockermaven</tag>
<images>
<image>
<name>apache/nifi</name>
<build>
<tags>
<tag>${project.version}-maven</tag>
</tags>
<dockerFile>Dockerfile</dockerFile>
<contextDir>${project.basedir}</contextDir>
<args>
<IMAGE_NAME>${docker.image.name}</IMAGE_NAME>
<IMAGE_TAG>${docker.image.tag}</IMAGE_TAG>
<UID>1000</UID>
<GID>1000</GID>
<NIFI_VERSION>${project.version}</NIFI_VERSION>
<NIFI_BINARY>target/nifi-${nifi.version}-bin.zip</NIFI_BINARY>
<NIFI_TOOLKIT_BINARY>target/nifi-toolkit-${nifi.version}-bin.zip</NIFI_TOOLKIT_BINARY>
<NIFI_SCRIPTS>target/sh</NIFI_SCRIPTS>
</args>
</build>
</image>
</images>
</configuration>
</execution>
</executions>
@ -125,7 +135,7 @@
</goals>
<configuration>
<arguments>
<argument>${project.version}-dockermaven</argument>
<argument>${project.version}-maven</argument>
<argument>${project.version}</argument>
</arguments>
<executable>${project.basedir}/integration-test.sh</executable>

View File

@ -25,7 +25,6 @@ language governing permissions and limitations under the License. -->
<nifi.version>${project.version}</nifi.version>
<docker.image.name>eclipse-temurin</docker.image.name>
<docker.image.tag>11-jre</docker.image.tag>
<docker.maintainer><![CDATA[Apache NiFi <dev@nifi.apache.org>]]></docker.maintainer>
</properties>
<modules>

View File

@ -21,21 +21,22 @@ LABEL maintainer="Apache NiFi <dev@nifi.apache.org>"
LABEL site="https://nifi.apache.org"
ARG NIFI_REGISTRY_BINARY
ARG NIFI_REGISTRY_BINARY_NAME
ARG NIFI_REGISTRY_SCRIPTS
ARG NIFI_REGISTRY_VERSION=2.0.0
ENV NIFI_REGISTRY_BASE_DIR /opt/nifi-registry
ENV NIFI_REGISTRY_HOME ${NIFI_REGISTRY_BASE_DIR}/nifi-registry-current
ADD sh/ ${NIFI_REGISTRY_BASE_DIR}/scripts/
ADD $NIFI_REGISTRY_SCRIPTS ${NIFI_REGISTRY_BASE_DIR}/scripts/
RUN chmod -R +x ${NIFI_REGISTRY_BASE_DIR}/scripts/*.sh \
&& apt-get update \
&& apt-get install -y unzip
COPY $NIFI_REGISTRY_BINARY $NIFI_REGISTRY_BASE_DIR
RUN unzip ${NIFI_REGISTRY_BASE_DIR}/nifi-registry-${NIFI_REGISTRY_VERSION}-bin.zip -d ${NIFI_REGISTRY_BASE_DIR} \
&& rm ${NIFI_REGISTRY_BASE_DIR}/nifi-registry-${NIFI_REGISTRY_VERSION}-bin.zip \
&& mv ${NIFI_REGISTRY_BASE_DIR}/nifi-registry-${NIFI_REGISTRY_VERSION} ${NIFI_REGISTRY_HOME} \
&& ln -s ${NIFI_REGISTRY_HOME} ${NIFI_REGISTRY_BASE_DIR}/nifi-registry-${NIFI_REGISTRY_VERSION}
RUN unzip ${NIFI_REGISTRY_BASE_DIR}/${NIFI_REGISTRY_BINARY_NAME} -d ${NIFI_REGISTRY_BASE_DIR} \
&& rm ${NIFI_REGISTRY_BASE_DIR}/${NIFI_REGISTRY_BINARY_NAME} \
&& ln -s ${NIFI_REGISTRY_BASE_DIR}/nifi-registry-${NIFI_REGISTRY_VERSION} ${NIFI_REGISTRY_HOME}
FROM eclipse-temurin:11-jre

View File

@ -32,8 +32,6 @@ test -z $(docker run --rm --entrypoint /bin/bash apache/nifi-registry:${TAG} -c
echo "Checking environment variables"
test "/opt/nifi-registry/nifi-registry-current" = "$(docker run --rm --entrypoint /bin/bash apache/nifi-registry:${TAG} -c 'echo -n $NIFI_REGISTRY_HOME')"
test "/opt/nifi-registry/nifi-registry-current" = "$(docker run --rm --entrypoint /bin/bash apache/nifi-registry:${TAG} -c "readlink \${NIFI_REGISTRY_BASE_DIR}/nifi-registry-${VERSION}")"
test "/opt/nifi-registry" = "$(docker run --rm --entrypoint /bin/bash apache/nifi-registry:${TAG} -c 'echo -n $NIFI_REGISTRY_BASE_DIR')"
echo "Starting NiFi Registry container..."

View File

@ -25,24 +25,6 @@
<id>docker</id>
<build>
<plugins>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<executions>
<execution>
<configuration>
<buildArgs>
<UID>1000</UID>
<GID>1000</GID>
<NIFI_REGISTRY_VERSION>${project.version}</NIFI_REGISTRY_VERSION>
<NIFI_REGISTRY_BINARY>target/nifi-registry-${project.version}-bin.zip</NIFI_REGISTRY_BINARY>
</buildArgs>
<repository>apache/nifi-registry</repository>
<tag>${project.version}-dockermaven</tag>
</configuration>
</execution>
</executions>
</plugin>
<!-- Copy generated artifacts -->
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
@ -64,11 +46,11 @@
</goals>
</execution>
<execution>
<id>copy-for-docker</id>
<id>copy-assembly-for-docker</id>
<phase>process-sources</phase>
<configuration>
<target name="copy assembly to nifi-registry-docker for image build">
<copy todir="${project.basedir}/target" overwrite="true" flatten="true">
<copy todir="${project.basedir}/target/" overwrite="true" flatten="true">
<fileset dir="${project.basedir}/../../nifi-registry-assembly/target" includes="*.zip">
<include name="*.zip" />
</fileset>
@ -81,7 +63,41 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<executions>
<execution>
<id>build-docker-image</id>
<phase>package</phase>
<goals>
<goal>build</goal>
</goals>
<configuration>
<images>
<image>
<name>apache/nifi-registry</name>
<build>
<tags>
<tag>${project.version}-maven</tag>
</tags>
<dockerFile>Dockerfile</dockerFile>
<contextDir>${project.basedir}</contextDir>
<args>
<UID>1000</UID>
<GID>1000</GID>
<NIFI_REGISTRY_VERSION>${project.version}</NIFI_REGISTRY_VERSION>
<NIFI_REGISTRY_SCRIPTS>target/sh</NIFI_REGISTRY_SCRIPTS>
<NIFI_REGISTRY_BINARY>target/nifi-registry-${project.version}-bin.zip</NIFI_REGISTRY_BINARY>
<NIFI_REGISTRY_BINARY_NAME>nifi-registry-${project.version}-bin.zip</NIFI_REGISTRY_BINARY_NAME>
</args>
</build>
</image>
</images>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>exec-maven-plugin</artifactId>
<groupId>org.codehaus.mojo</groupId>
@ -95,7 +111,7 @@
<configuration>
<skip>${skipTests}</skip>
<arguments>
<argument>${project.version}-dockermaven</argument>
<argument>${project.version}-maven</argument>
<argument>${project.version}</argument>
</arguments>
<executable>${project.basedir}/integration-test.sh</executable>
@ -103,7 +119,6 @@
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>

View File

@ -30,6 +30,3 @@ test 2 -eq $? || exit 1
docker run --rm $IMAGE file-manager invalid 1>/dev/null 2>&1
test 1 -eq $? || exit 1
docker run --rm $IMAGE flow-analyzer invalid 1>/dev/null 2>&1
test 1 -eq $? || exit 1

View File

@ -154,19 +154,33 @@ language governing permissions and limitations under the License. -->
</executions>
</plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<executions>
<execution>
<id>build-docker-image</id>
<phase>package</phase>
<goals>
<goal>build</goal>
</goals>
<configuration>
<contextDirectory>./target/docker-build</contextDirectory>
<buildArgs>
<UID>1000</UID>
<GID>1000</GID>
<NIFI_TOOLKIT_VERSION>${project.version}</NIFI_TOOLKIT_VERSION>
</buildArgs>
<repository>apache/nifi-toolkit</repository>
<tag>${project.version}</tag>
<images>
<image>
<name>apache/nifi-toolkit</name>
<build>
<tags>
<tag>${project.version}-maven</tag>
</tags>
<dockerFile>Dockerfile</dockerFile>
<contextDir>${project.basedir}/target/docker-build</contextDir>
<args>
<UID>1000</UID>
<GID>1000</GID>
<NIFI_TOOLKIT_VERSION>${project.version}</NIFI_TOOLKIT_VERSION>
</args>
</build>
</image>
</images>
</configuration>
</execution>
</executions>
@ -183,7 +197,7 @@ language governing permissions and limitations under the License. -->
</goals>
<configuration>
<arguments>
<argument>${project.version}</argument>
<argument>${project.version}-maven</argument>
</arguments>
<executable>${project.basedir}/docker/tests/exit-codes.sh</executable>
</configuration>
@ -196,7 +210,7 @@ language governing permissions and limitations under the License. -->
</goals>
<configuration>
<arguments>
<argument>${project.version}</argument>
<argument>${project.version}-maven</argument>
</arguments>
<executable>${project.basedir}/docker/tests/tls-toolkit.sh</executable>
</configuration>

14
pom.xml
View File

@ -882,17 +882,9 @@
</executions>
</plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<version>1.4.13</version>
<executions>
<execution>
<id>default</id>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.42.0</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>