Skip to content

Commit 6d4f536

Browse files
committed
- OPA
- Spark (WIP)
1 parent e6606ef commit 6d4f536

File tree

2 files changed

+42
-32
lines changed

2 files changed

+42
-32
lines changed

opa/Dockerfile

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -86,32 +86,41 @@ FROM stackable/image/vector
8686

8787
ARG PRODUCT
8888
ARG RELEASE
89+
ARG STACKABLE_USER_UID
8990

9091
LABEL name="Open Policy Agent" \
9192
maintainer="info@stackable.tech" \
9293
vendor="Stackable GmbH" \
9394
version="${PRODUCT}" \
9495
release="${RELEASE}" \
95-
summary="The Stackable image for OPA." \
96+
summary="The Stackable image for Open Policy Agent (OPA)." \
9697
description="This image is deployed by the Stackable Operator for OPA."
9798

98-
RUN microdnf update && \
99-
microdnf install \
100-
# Required for filtering logs
101-
jq && \
102-
microdnf clean all && \
103-
rm -rf /var/cache/yum
104-
10599
COPY opa/licenses /licenses
106100

107-
USER stackable
108-
WORKDIR /stackable/opa
101+
COPY --from=opa-builder --chown=${STACKABLE_USER_UID}:0 /opa/opa /stackable/opa/opa
102+
COPY --from=opa-bundle-builder --chown=${STACKABLE_USER_UID}:0 /opa-bundle-builder/target/release/stackable-opa-bundle-builder /stackable/opa-bundle-builder
103+
COPY --from=multilog-builder --chown=${STACKABLE_USER_UID}:0 /daemontools/admin/daemontools/command/multilog /stackable/multilog
109104

110-
COPY --from=opa-builder /opa/opa /stackable/opa/opa
111-
COPY --from=opa-bundle-builder --chown=stackable:stackable /opa-bundle-builder/target/release/stackable-opa-bundle-builder /stackable/opa-bundle-builder
112-
COPY --from=multilog-builder --chown=stackable:stackable /daemontools/admin/daemontools/command/multilog /stackable/multilog
105+
COPY --chown=${STACKABLE_USER_UID}:0 opa/stackable/bin /stackable/opa/bin
113106

114-
COPY --chown=stackable:stackable opa/stackable/bin /stackable/opa/bin
107+
RUN <<EOF
108+
microdnf update
109+
110+
# jq: Required for filtering logs
111+
microdnf install \
112+
jq
113+
microdnf clean all
114+
rm -rf /var/cache/yum
115+
116+
# All files and folders owned by root to support running as arbitrary users
117+
# This is best practice as all container users will belong to the root group (0)
118+
chown -R ${STACKABLE_USER_UID}:0 /stackable
119+
chmod -R g=u /stackable
120+
EOF
121+
122+
USER ${STACKABLE_USER_UID}
123+
WORKDIR /stackable/opa
115124

116125
ENV PATH="${PATH}:/stackable/opa:/stackable/opa/bin"
117126

spark-k8s/Dockerfile

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ FROM stackable/image/hbase AS hbase-builder
1212
FROM stackable/image/java-devel AS spark-source-builder
1313

1414
ARG PRODUCT
15+
ARG STACKABLE_USER_UID
1516

1617
RUN <<EOF
1718
microdnf update
@@ -34,10 +35,10 @@ EOF
3435

3536
WORKDIR /stackable/spark
3637

37-
COPY --chown=stackable:stackable \
38+
COPY --chown=${STACKABLE_USER_UID}:0 \
3839
spark-k8s/stackable/patches/apply_patches.sh \
3940
patches/apply_patches.sh
40-
COPY --chown=stackable:stackable \
41+
COPY --chown=${STACKABLE_USER_UID}:0 \
4142
spark-k8s/stackable/patches/${PRODUCT} \
4243
patches/${PRODUCT}
4344

@@ -52,6 +53,7 @@ ARG PRODUCT
5253
ARG HADOOP
5354
ARG HBASE
5455
ARG HBASE_CONNECTOR
56+
ARG STACKABLE_USER_UID
5557

5658
RUN <<EOF
5759
microdnf update
@@ -70,7 +72,7 @@ WORKDIR /stackable
7072
# versions used by Spark. The pom.xml defines child modules which are
7173
# not required and not copied, therefore mvn must be called with the
7274
# parameter --non-recursive.
73-
COPY --chown=stackable:stackable --from=spark-source-builder \
75+
COPY --chown=${STACKABLE_USER_UID}:0 --from=spark-source-builder \
7476
/stackable/spark/pom.xml \
7577
spark/
7678

@@ -83,10 +85,10 @@ EOF
8385

8486
# Patch the hbase-connectors source code
8587
WORKDIR /stackable/hbase-connectors
86-
COPY --chown=stackable:stackable \
88+
COPY --chown=${STACKABLE_USER_UID}:0 \
8789
spark-k8s/stackable/hbase-connectors-patches/apply_patches.sh \
8890
patches/apply_patches.sh
89-
COPY --chown=stackable:stackable \
91+
COPY --chown=${STACKABLE_USER_UID}:0 \
9092
spark-k8s/stackable/hbase-connectors-patches/${HBASE_CONNECTOR} \
9193
patches/${HBASE_CONNECTOR}
9294
RUN patches/apply_patches.sh ${HBASE_CONNECTOR}
@@ -173,7 +175,7 @@ ARG TINI
173175

174176
WORKDIR /stackable/spark-${PRODUCT}
175177

176-
COPY --chown=stackable:stackable --from=spark-source-builder \
178+
COPY --chown=${STACKABLE_USER_UID}:0 --from=spark-source-builder \
177179
/stackable/spark/ \
178180
./
179181

@@ -200,35 +202,35 @@ RUN curl -o /usr/bin/tini "https://repo.stackable.tech/repository/packages/tini/
200202
WORKDIR /stackable/spark-${PRODUCT}/dist/jars
201203

202204
# Copy modules required for s3a://
203-
COPY --from=hadoop-builder --chown=stackable:stackable \
205+
COPY --from=hadoop-builder --chown=${STACKABLE_USER_UID}:0 \
204206
/stackable/hadoop/share/hadoop/tools/lib/hadoop-aws-${HADOOP}.jar \
205207
/stackable/hadoop/share/hadoop/tools/lib/aws-java-sdk-bundle-${AWS_JAVA_SDK_BUNDLE}.jar \
206208
./
207209

208210
# Copy modules required for abfs://
209-
COPY --from=hadoop-builder --chown=stackable:stackable \
211+
COPY --from=hadoop-builder --chown=${STACKABLE_USER_UID}:0 \
210212
/stackable/hadoop/share/hadoop/tools/lib/hadoop-azure-${HADOOP}.jar \
211213
/stackable/hadoop/share/hadoop/tools/lib/azure-storage-${AZURE_STORAGE}.jar \
212214
/stackable/hadoop/share/hadoop/tools/lib/azure-keyvault-core-${AZURE_KEYVAULT_CORE}.jar \
213215
./
214216

215217
# Copy the HBase connector including required modules
216-
COPY --from=hbase-connectors-builder --chown=stackable:stackable \
218+
COPY --from=hbase-connectors-builder --chown=${STACKABLE_USER_UID}:0 \
217219
/stackable/spark/jars/* \
218220
./
219221

220222
# Copy modules required to access HBase
221-
COPY --from=hbase-builder --chown=stackable:stackable \
223+
COPY --from=hbase-builder --chown=${STACKABLE_USER_UID}:0 \
222224
/stackable/hbase/lib/shaded-clients/hbase-shaded-client-byo-hadoop-${HBASE}.jar \
223225
/stackable/hbase/lib/shaded-clients/hbase-shaded-mapreduce-${HBASE}.jar \
224226
./
225227
# Copy modules required to access HBase if $HBASE == 2.4.x
226-
COPY --from=hbase-builder --chown=stackable:stackable \
228+
COPY --from=hbase-builder --chown=${STACKABLE_USER_UID}:0 \
227229
/stackable/hbase/lib/client-facing-thirdparty/htrace-core4-*-incubating.jar \
228230
/stackable/hbase/lib/client-facing-thirdparty/slf4j-reload4j-*.jar \
229231
./
230232
# Copy modules required to access HBase if $HBASE == 2.6.x
231-
COPY --from=hbase-builder --chown=stackable:stackable \
233+
COPY --from=hbase-builder --chown=${STACKABLE_USER_UID}:0 \
232234
/stackable/hbase/lib/client-facing-thirdparty/opentelemetry-api-*.jar \
233235
/stackable/hbase/lib/client-facing-thirdparty/opentelemetry-context-*.jar \
234236
/stackable/hbase/lib/client-facing-thirdparty/opentelemetry-semconv-*-alpha.jar \
@@ -271,7 +273,7 @@ ARG PRODUCT
271273
ARG PYTHON
272274
ARG RELEASE
273275
ARG JMX_EXPORTER
274-
276+
ARG STACKABLE_USER_UID
275277

276278
LABEL name="Apache Spark" \
277279
maintainer="info@stackable.tech" \
@@ -306,21 +308,20 @@ ENV PATH=$SPARK_HOME:$PATH:/bin:$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$HOME/.local/b
306308
ENV PYSPARK_PYTHON=/usr/bin/python
307309
ENV PYTHONPATH=$SPARK_HOME/python
308310

309-
COPY --chown=stackable:stackable --from=spark-builder /stackable/spark-${PRODUCT}/dist /stackable/spark
310-
COPY --chown=stackable:stackable --from=spark-builder /stackable/spark-${PRODUCT}/assembly/target/bom.json /stackable/spark/spark-${PRODUCT}.cdx.json
311-
COPY --chown=stackable:stackable --from=spark-builder /stackable/jmx /stackable/jmx
311+
COPY --chown=${STACKABLE_USER_UID}:0 --from=spark-builder /stackable/spark-${PRODUCT}/dist /stackable/spark
312+
COPY --chown=${STACKABLE_USER_UID}:0 --from=spark-builder /stackable/spark-${PRODUCT}/assembly/target/bom.json /stackable/spark/spark-${PRODUCT}.cdx.json
313+
COPY --chown=${STACKABLE_USER_UID}:0 --from=spark-builder /stackable/jmx /stackable/jmx
312314
COPY --from=spark-builder /usr/bin/tini /usr/bin/tini
313315

314316
RUN ln -s "/stackable/jmx/jmx_prometheus_javaagent-${JMX_EXPORTER}.jar" /stackable/jmx/jmx_prometheus_javaagent.jar \
315317
# Symlink example jar, so that we can easily use it in tests
316318
&& ln -s /stackable/spark/examples/jars/spark-examples_*.jar /stackable/spark/examples/jars/spark-examples.jar
317319

318-
USER stackable
320+
USER ${STACKABLE_USER_UID}
319321
WORKDIR /stackable
320322

321323
COPY spark-k8s/stackable /stackable
322324
COPY spark-k8s/licenses /licenses
323325

324-
325326
WORKDIR /stackable/spark
326327
ENTRYPOINT [ "/stackable/run-spark.sh" ]

0 commit comments

Comments
 (0)