@@ -7,59 +7,78 @@ ARG PRODUCT
7
7
ARG MAVEN_VERSION="3.9.8"
8
8
ARG STACKABLE_USER_UID
9
9
10
- RUN microdnf update && \
11
- microdnf clean all && \
12
- rm -rf /var/cache/yum
10
+ RUN <<EOF
11
+ microdnf update
12
+ microdnf clean all
13
+ rm -rf /var/cache/yum
14
+ EOF
13
15
14
16
# NOTE: From NiFi 2.0.0 upwards Apache Maven 3.9.6+ is required. As of 2024-07-04 the java-devel image
15
17
# ships 3.6.3. This will update maven accordingly depending on the version. The error is due to the maven-enforer-plugin.
16
18
#
17
19
# [ERROR] Rule 2: org.apache.maven.enforcer.rules.version.RequireMavenVersion failed with message:
18
20
# [ERROR] Detected Maven Version: 3.6.3 is not in the allowed range [3.9.6,).
19
21
#
20
- WORKDIR /tmp
21
- RUN if [[ "${PRODUCT}" != 1.* ]] ; then \
22
- curl "https://repo.stackable.tech/repository/packages/maven/apache-maven-${MAVEN_VERSION}-bin.tar.gz" | tar -xzC . && \
23
- ln -sf /tmp/apache-maven-${MAVEN_VERSION}/bin/mvn /usr/bin/mvn ; \
24
- fi
22
+ RUN <<EOF
23
+ if [[ "${PRODUCT}" != 1.* ]] ; then
24
+ cd /tmp
25
+ curl "https://repo.stackable.tech/repository/packages/maven/apache-maven-${MAVEN_VERSION}-bin.tar.gz" | tar -xzC .
26
+ ln -sf /tmp/apache-maven-${MAVEN_VERSION}/bin/mvn /usr/bin/mvn
27
+ fi
28
+ EOF
25
29
26
30
USER ${STACKABLE_USER_UID}
27
31
WORKDIR /stackable
28
32
29
33
COPY --chown=${STACKABLE_USER_UID}:0 nifi/stackable/patches /stackable/patches
30
34
31
- RUN curl 'https://repo.stackable.tech/repository/m2/tech/stackable/nifi/stackable-bcrypt/1.0-SNAPSHOT/stackable-bcrypt-1.0-20240508.153334-1-jar-with-dependencies.jar' \
32
- # This used to be located in /bin/stackable-bcrypt.jar. We create a softlink for /bin/stackable-bcrypt.jar in the main container for backwards compatibility.
33
- -o /stackable/stackable-bcrypt.jar && \
34
- # Get the source release from nexus
35
- curl "https://repo.stackable.tech/repository/packages/nifi/nifi-${PRODUCT}-source-release.zip" -o "/stackable/nifi-${PRODUCT}-source-release.zip" && \
36
- unzip "nifi-${PRODUCT}-source-release.zip" && \
37
- # Clean up downloaded source after unzipping
38
- rm -rf "nifi-${PRODUCT}-source-release.zip" && \
39
- # The NiFi "binary" ends up in a folder named "nifi-${PRODUCT}" which should be copied to /stackable
40
- # from /stackable/nifi-${PRODUCT}-src/nifi-assembly/target/nifi-${PRODUCT}-bin/nifi-${PRODUCT} (see later steps)
41
- # Therefore we add the suffix "-src" to be able to copy the binary and remove the unzipped sources afterwards.
42
- mv nifi-${PRODUCT} nifi-${PRODUCT}-src && \
43
- # Apply patches
44
- chmod +x patches/apply_patches.sh && \
45
- patches/apply_patches.sh ${PRODUCT} && \
46
- # Build NiFi
47
- cd /stackable/nifi-${PRODUCT}-src/ && \
48
- # NOTE: Since NiFi 2.0.0 PutIceberg Processor and services were removed, so including the `include-iceberg` profile does nothing.
49
- # Additionally some modules were moved to optional build profiles, so we need to add `include-hadoop` to get `nifi-parquet-nar` for example.
50
- if [[ "${PRODUCT}" != 1.* ]] ; then \
51
- mvn --batch-mode --no-transfer-progress clean install -Dmaven.javadoc.skip=true -DskipTests --activate-profiles include-hadoop,include-hadoop-aws,include-hadoop-azure,include-hadoop-gcp ; \
52
- else \
53
- mvn --batch-mode --no-transfer-progress clean install -Dmaven.javadoc.skip=true -DskipTests --activate-profiles include-iceberg,include-hadoop-aws,include-hadoop-azure,include-hadoop-gcp ; \
54
- fi && \
55
- # Copy the binaries to the /stackable folder
56
- mv /stackable/nifi-${PRODUCT}-src/nifi-assembly/target/nifi-${PRODUCT}-bin/nifi-${PRODUCT} /stackable/nifi-${PRODUCT} && \
57
- # Copy the SBOM as well
58
- mv /stackable/nifi-${PRODUCT}-src/nifi-assembly/target/bom.json /stackable/nifi-${PRODUCT}/nifi-${PRODUCT}.cdx.json && \
59
- # Remove the unzipped sources
60
- rm -rf /stackable/nifi-${PRODUCT}-src && \
61
- # Remove generated docs in binary
62
- rm -rf /stackable/nifi-${PRODUCT}/docs
35
+ RUN <<EOF
36
+ # This used to be located in /bin/stackable-bcrypt.jar. We create a softlink for /bin/stackable-bcrypt.jar in the main container for backwards compatibility.
37
+ curl 'https://repo.stackable.tech/repository/m2/tech/stackable/nifi/stackable-bcrypt/1.0-SNAPSHOT/stackable-bcrypt-1.0-20240508.153334-1-jar-with-dependencies.jar' \
38
+ -o /stackable/stackable-bcrypt.jar
39
+
40
+ # Get the source release from nexus
41
+ curl "https://repo.stackable.tech/repository/packages/nifi/nifi-${PRODUCT}-source-release.zip" -o "/stackable/nifi-${PRODUCT}-source-release.zip"
42
+ unzip "nifi-${PRODUCT}-source-release.zip"
43
+
44
+ # Clean up downloaded source after unzipping
45
+ rm -rf "nifi-${PRODUCT}-source-release.zip"
46
+
47
+ # The NiFi "binary" ends up in a folder named "nifi-${PRODUCT}" which should be copied to /stackable
48
+ # from /stackable/nifi-${PRODUCT}-src/nifi-assembly/target/nifi-${PRODUCT}-bin/nifi-${PRODUCT} (see later steps)
49
+ # Therefore we add the suffix "-src" to be able to copy the binary and remove the unzipped sources afterwards.
50
+ mv nifi-${PRODUCT} nifi-${PRODUCT}-src
51
+
52
+ # Apply patches
53
+ chmod +x patches/apply_patches.sh
54
+ patches/apply_patches.sh ${PRODUCT}
55
+
56
+ # Build NiFi
57
+ cd /stackable/nifi-${PRODUCT}-src/
58
+
59
+ # NOTE: Since NiFi 2.0.0 PutIceberg Processor and services were removed, so including the `include-iceberg` profile does nothing.
60
+ # Additionally some modules were moved to optional build profiles, so we need to add `include-hadoop` to get `nifi-parquet-nar` for example.
61
+ if [[ "${PRODUCT}" != 1.* ]] ; then
62
+ mvn --batch-mode --no-transfer-progress clean install -Dmaven.javadoc.skip=true -DskipTests --activate-profiles include-hadoop,include-hadoop-aws,include-hadoop-azure,include-hadoop-gcp
63
+ else
64
+ mvn --batch-mode --no-transfer-progress clean install -Dmaven.javadoc.skip=true -DskipTests --activate-profiles include-iceberg,include-hadoop-aws,include-hadoop-azure,include-hadoop-gcp
65
+ fi
66
+
67
+ # Copy the binaries to the /stackable folder
68
+ mv /stackable/nifi-${PRODUCT}-src/nifi-assembly/target/nifi-${PRODUCT}-bin/nifi-${PRODUCT} /stackable/nifi-${PRODUCT}
69
+
70
+ # Copy the SBOM as well
71
+ mv /stackable/nifi-${PRODUCT}-src/nifi-assembly/target/bom.json /stackable/nifi-${PRODUCT}/nifi-${PRODUCT}.cdx.json
72
+
73
+ # Remove the unzipped sources
74
+ rm -rf /stackable/nifi-${PRODUCT}-src
75
+
76
+ # Remove generated docs in binary
77
+ rm -rf /stackable/nifi-${PRODUCT}/docs
78
+
79
+ # Set correct permissions
80
+ chmod -R g=u /stackable
81
+ EOF
63
82
64
83
FROM stackable/image/java-base AS final
65
84
@@ -83,8 +102,6 @@ COPY --chown=${STACKABLE_USER_UID}:0 nifi/licenses /licenses
83
102
COPY --chown=${STACKABLE_USER_UID}:0 nifi/python /stackable/python
84
103
85
104
RUN <<EOF
86
- ln -s /stackable/nifi-${PRODUCT} /stackable/nifi
87
-
88
105
microdnf update
89
106
90
107
# python-pip: Required to install Python packages
@@ -96,24 +113,38 @@ microdnf clean all
96
113
rm -rf /var/cache/yum
97
114
98
115
# The nipyapi is required until NiFi 2.0.x for the ReportingTaskJob
116
+ # This can be removed once the 1.x.x line is removed
99
117
pip install --no-cache-dir \
100
118
nipyapi==0.19.1
101
119
102
120
# For backwards compatibility we create a softlink in /bin where the jar used to be as long as we are root
103
121
# This can be removed once older versions / operators using this are no longer supported
104
122
ln -s /stackable/stackable-bcrypt.jar /bin/stackable-bcrypt.jar
105
123
106
- # All files and folders owned by root group to support running as arbitrary users.
107
- # This is best practice as all container users will belong to the root group (0).
108
- chown -R ${STACKABLE_USER_UID}:0 /stackable
109
- chmod -R g=u /stackable
124
+ ln -s /stackable/nifi-${PRODUCT} /stackable/nifi
125
+
126
+ # fix missing permissions / ownership
127
+ chown --no-dereference ${STACKABLE_USER_UID}:0 /stackable/nifi
128
+ chmod --recursive g=u /stackable/python
129
+ chmod --recursive g=u /stackable/bin
130
+ chmod g=u /stackable/nifi-${PRODUCT}
131
+ EOF
132
+
133
+ # ----------------------------------------
134
+ # Checks
135
+ # This section is to run final checks to ensure the created final images
136
+ # adhere to several minimal requirements like:
137
+ # - check file permissions and ownerships
138
+ # ----------------------------------------
139
+
140
+ # Check that permissions and ownership in /stackable are set correctly
141
+ # This will fail and stop the build if any mismatches are found.
142
+ RUN <<EOF
143
+ /bin/check-permissions-ownership.sh /stackable ${STACKABLE_USER_UID} 0
110
144
EOF
111
145
112
146
# ----------------------------------------
113
- # Attention: We are changing the group of all files in /stackable directly above
114
- # If you do any file based actions (copying / creating etc.) below this comment you
115
- # absolutely need to make sure that the correct permissions are applied!
116
- # chown ${STACKABLE_USER_UID}:0
147
+ # Attention: Do not perform any file based actions (copying/creating etc.) below this comment because the permissions would not be checked.
117
148
# ----------------------------------------
118
149
119
150
USER ${STACKABLE_USER_UID}
0 commit comments