@@ -13,12 +13,20 @@ FROM stackable/image/java-devel AS hive-builder
13
13
ARG PRODUCT
14
14
ARG HADOOP
15
15
ARG JMX_EXPORTER
16
+ ARG AWS_JAVA_SDK_BUNDLE
17
+ ARG AZURE_STORAGE
18
+ ARG AZURE_KEYVAULT_CORE
16
19
ARG STACKABLE_USER_UID
17
20
18
21
# Setting this to anything other than "true" will keep the cache folders around (e.g. for Maven, NPM etc.)
19
22
# This can be used to speed up builds when disk space is of no concern.
20
23
ARG DELETE_CACHES="true"
21
24
25
+ # It is useful to see which version of Hadoop is used at a glance
26
+ # Therefore the use of the full name here
27
+ # TODO: Do we really need all of Hadoop in here?
28
+ COPY --chown=${STACKABLE_USER_UID}:0 --from=hadoop-builder /stackable/hadoop /stackable/hadoop-${HADOOP}
29
+
22
30
COPY --chown=${STACKABLE_USER_UID}:0 hive/stackable /stackable
23
31
24
32
USER ${STACKABLE_USER_UID}
@@ -58,6 +66,18 @@ rm -rf /stackable/apache-hive-${PRODUCT}-src
58
66
curl "https://repo.stackable.tech/repository/packages/jmx-exporter/jmx_prometheus_javaagent-${JMX_EXPORTER}.jar" -o "/stackable/jmx/jmx_prometheus_javaagent-${JMX_EXPORTER}.jar"
59
67
ln -s "/stackable/jmx/jmx_prometheus_javaagent-${JMX_EXPORTER}.jar" /stackable/jmx/jmx_prometheus_javaagent.jar
60
68
69
+ # The next two sections for S3 and Azure use hardcoded version numbers on purpose instead of wildcards
70
+ # This way the build will fail should one of the files not be available anymore in a later Hadoop version!
71
+
72
+ # Add S3 Support for Hive (support for s3a://)
73
+ cp /stackable/hadoop-${HADOOP}/share/hadoop/tools/lib/hadoop-aws-${HADOOP}.jar /stackable/apache-hive-metastore-${PRODUCT}-bin/lib/
74
+ cp /stackable/hadoop-${HADOOP}/share/hadoop/tools/lib/aws-java-sdk-bundle-${AWS_JAVA_SDK_BUNDLE}.jar /stackable/apache-hive-metastore-${PRODUCT}-bin/lib/
75
+
76
+ # Add Azure ABFS support (support for abfs://)
77
+ cp /stackable/hadoop-${HADOOP}/share/hadoop/tools/lib/hadoop-azure-${HADOOP}.jar /stackable/apache-hive-metastore-${PRODUCT}-bin/lib/
78
+ cp /stackable/hadoop-${HADOOP}/share/hadoop/tools/lib/azure-storage-${AZURE_STORAGE}.jar /stackable/apache-hive-metastore-${PRODUCT}-bin/lib/
79
+ cp /stackable/hadoop-${HADOOP}/share/hadoop/tools/lib/azure-keyvault-core-${AZURE_KEYVAULT_CORE}.jar /stackable/apache-hive-metastore-${PRODUCT}-bin/lib/
80
+
61
81
# We're removing these to make the intermediate layer smaller
62
82
# This can be necessary even though it's only a builder image because the GitHub Action Runners only have very limited space available
63
83
# and we are sometimes running into errors because we're out of space.
@@ -67,6 +87,9 @@ if [ "${DELETE_CACHES}" = "true" ] ; then
67
87
rm -rf /stackable/.npm/*
68
88
rm -rf /stackable/.cache/*
69
89
fi
90
+
91
+ # change groups
92
+ chmod --recursive g=u /stackable
70
93
EOF
71
94
72
95
@@ -75,9 +98,6 @@ FROM stackable/image/java-base AS final
75
98
ARG PRODUCT
76
99
ARG HADOOP
77
100
ARG RELEASE
78
- ARG AWS_JAVA_SDK_BUNDLE
79
- ARG AZURE_STORAGE
80
- ARG AZURE_KEYVAULT_CORE
81
101
ARG STACKABLE_USER_UID
82
102
83
103
@@ -106,47 +126,45 @@ LABEL io.k8s.display-name="${NAME}"
106
126
WORKDIR /stackable
107
127
108
128
COPY --chown=${STACKABLE_USER_UID}:0 --from=hive-builder /stackable/apache-hive-metastore-${PRODUCT}-bin /stackable/apache-hive-metastore-${PRODUCT}-bin
129
+ COPY --chown=${STACKABLE_USER_UID}:0 --from=hive-builder /stackable/hadoop-${HADOOP} /stackable/hadoop-${HADOOP}
130
+ COPY --chown=${STACKABLE_USER_UID}:0 --from=hive-builder /stackable/jmx /stackable/jmx
109
131
110
- # It is useful to see which version of Hadoop is used at a glance
111
- # Therefore the use of the full name here
112
- # TODO: Do we really need all of Hadoop in here?
113
- COPY --chown=${STACKABLE_USER_UID}:0 --from=hadoop-builder /stackable/hadoop /stackable/hadoop-${HADOOP}
132
+ COPY hive/licenses /licenses
114
133
115
134
RUN <<EOF
116
135
microdnf update
117
136
microdnf clean all
118
137
rpm -qa --qf "%{NAME}-%{VERSION}-%{RELEASE}\n " | sort > /stackable/package_manifest.txt
138
+ chown ${STACKABLE_USER_UID}:0 /stackable/package_manifest.txt
139
+ chmod g=u /stackable/package_manifest.txt
119
140
rm -rf /var/cache/yum
120
141
121
142
ln -s /stackable/apache-hive-metastore-${PRODUCT}-bin /stackable/hive-metastore
143
+ chown -h ${STACKABLE_USER_UID}:0 /stackable/hive-metastore
144
+ chmod g=u /stackable/hive-metastore
122
145
ln -s /stackable/hadoop-${HADOOP} /stackable/hadoop
146
+ chown -h ${STACKABLE_USER_UID}:0 /stackable/hadoop
147
+ chmod g=u /stackable/hadoop
123
148
124
- # The next two sections for S3 and Azure use hardcoded version numbers on purpose instead of wildcards
125
- # This way the build will fail should one of the files not be available anymore in a later Hadoop version!
149
+ # fix missing permissions
150
+ chmod --recursive g=u /stackable/jmx
151
+ EOF
126
152
127
- # Add S3 Support for Hive (support for s3a://)
128
- cp /stackable/hadoop/share/hadoop/tools/lib/hadoop-aws-${HADOOP}.jar /stackable/hive-metastore/lib/
129
- cp /stackable/hadoop/share/hadoop/tools/lib/aws-java-sdk-bundle-${AWS_JAVA_SDK_BUNDLE}.jar /stackable/hive-metastore/lib/
153
+ # ----------------------------------------
154
+ # Checks
155
+ # This section is to run final checks to ensure the created final images
156
+ # adhere to several minimal requirements like:
157
+ # - check file permissions and ownerships
158
+ # ----------------------------------------
130
159
131
- # Add Azure ABFS support (support for abfs://)
132
- cp /stackable/hadoop/share/hadoop/tools/lib/hadoop-azure-${HADOOP}.jar /stackable/hive-metastore/lib/
133
- cp /stackable/hadoop/share/hadoop/tools/lib/azure-storage-${AZURE_STORAGE}.jar /stackable/hive-metastore/lib/
134
- cp /stackable/hadoop/share/hadoop/tools/lib/azure-keyvault-core-${AZURE_KEYVAULT_CORE}.jar /stackable/hive-metastore/lib/
135
-
136
- # All files and folders owned by root group to support running as arbitrary users.
137
- # This is best practice as all container users will belong to the root group (0).
138
- chown -R ${STACKABLE_USER_UID}:0 /stackable
139
- chmod -R g=u /stackable
160
+ # Check that permissions and ownership in /stackable are set correctly
161
+ # This will fail and stop the build if any mismatches are found.
162
+ RUN <<EOF
163
+ /bin/check-permissions-ownership.sh /stackable ${STACKABLE_USER_UID} 0
140
164
EOF
141
165
142
- COPY --chown=${STACKABLE_USER_UID}:0 --from=hive-builder /stackable/jmx /stackable/jmx
143
- COPY hive/licenses /licenses
144
-
145
166
# ----------------------------------------
146
- # Attention: We are changing the group of all files in /stackable directly above
147
- # If you do any file based actions (copying / creating etc.) below this comment you
148
- # absolutely need to make sure that the correct permissions are applied!
149
- # chown ${STACKABLE_USER_UID}:0
167
+ # Attention: Do not perform any file based actions (copying/creating etc.) below this comment because the permissions would not be checked.
150
168
# ----------------------------------------
151
169
152
170
USER ${STACKABLE_USER_UID}
0 commit comments