Skip to content

Commit 81fc95c

Browse files
committed
check permissions
1 parent 28f0039 commit 81fc95c

File tree

1 file changed

+25
-15
lines changed

1 file changed

+25
-15
lines changed

trino/Dockerfile

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ RUN curl "https://repo.stackable.tech/repository/packages/trino-server/trino-ser
2727
COPY --chown=${STACKABLE_USER_UID}:0 trino/stackable/patches/apply_patches.sh /stackable/trino-server-${PRODUCT}-src/patches/apply_patches.sh
2828
COPY --chown=${STACKABLE_USER_UID}:0 trino/stackable/patches/${PRODUCT} /stackable/trino-server-${PRODUCT}-src/patches/${PRODUCT}
2929
COPY --chown=${STACKABLE_USER_UID}:0 --from=trino-storage-connector-image /stackable/trino-storage-${PRODUCT}-src/target/trino-storage-${PRODUCT} /trino-storage-${PRODUCT}
30-
# do not copy patches -> .dockerignore?
3130
COPY --chown=${STACKABLE_USER_UID}:0 trino/stackable/jmx /stackable/jmx
3231

3332
# adding a hadolint ignore for SC2215, due to https://github.com/hadolint/hadolint/issues/980
@@ -66,13 +65,16 @@ rm -r /stackable/.m2
6665
# JMX Exporter
6766
curl --fail https://repo.stackable.tech/repository/packages/jmx-exporter/jmx_prometheus_javaagent-${JMX_EXPORTER}.jar -o /stackable/jmx/jmx_prometheus_javaagent-${JMX_EXPORTER}.jar
6867
chmod +x /stackable/jmx/jmx_prometheus_javaagent-${JMX_EXPORTER}.jar
68+
6969
# Storage connector
7070
mv /trino-storage-${PRODUCT}/ /stackable/trino-server-${PRODUCT}/plugin/trino-storage-${PRODUCT}/
71+
7172
# Softlinks
7273
ln -s /stackable/jmx/jmx_prometheus_javaagent-${JMX_EXPORTER}.jar /stackable/jmx/jmx_prometheus_javaagent.jar
7374
ln -s /stackable/trino-server-${PRODUCT} /stackable/trino-server
74-
# We need to change groups here and not in the final image (file changes bloat images)
75-
chmod -R g=u /stackable
75+
76+
# Set correct permissions
77+
chmod --recursive g=u /stackable
7678
EOF
7779

7880
FROM stackable/image/java-base
@@ -90,33 +92,41 @@ LABEL \
9092
summary="The Stackable image for Trino." \
9193
description="This image is deployed by the Stackable Operator for Trino."
9294

93-
RUN microdnf update && \
94-
microdnf install \
95+
RUN <<EOF
96+
microdnf update
97+
microdnf install \
9598
gzip \
9699
httpd-tools \
97100
python \
98101
tar \
99102
# Required by snappy and duckdb, see https://github.com/trinodb/trino/pull/25143
100103
libstdc++ \
101-
zip && \
102-
microdnf clean all && \
103-
rm -rf /var/cache/yum
104-
105-
WORKDIR /stackable
104+
zip
105+
microdnf clean all
106+
rm -rf /var/cache/yum
107+
EOF
106108

107109
# If /stackable has any build artifacts / leftovers make sure its removed properly
108110
# or only copy what is actually required in the final image like:
109111
# COPY --from=trino-builder --chown=${STACKABLE_USER_UID}:0 /stackable/foo /stackable/foo
110112
COPY --from=trino-builder --chown=${STACKABLE_USER_UID}:0 /stackable /stackable
111-
112113
COPY --chown=${STACKABLE_USER_UID}:0 trino/licenses /licenses
113114

114115
# ----------------------------------------
115-
# Attention:
116-
# If you do any file based actions (copying / creating etc.) below this comment you
117-
# absolutely need to make sure that the correct permissions are applied!
118-
# chown ${STACKABLE_USER_UID}:0
116+
# Checks
117+
# This section is to run final checks to ensure the created final images
118+
# adhere to several minimal requirements like:
119+
# - check file permissions and ownerships
120+
# ----------------------------------------
121+
122+
# Check that permissions and ownership in /stackable are set correctly
123+
# This will fail and stop the build if any mismatches are found.
124+
RUN <<EOF
125+
/bin/check-permissions-ownership.sh /stackable ${STACKABLE_USER_UID} 0
126+
EOF
127+
119128
# ----------------------------------------
129+
# Attention: Do not perform any file based actions (copying/creating etc.) below this comment because the permissions would not be checked.
120130

121131
USER ${STACKABLE_USER_UID}
122132
WORKDIR /stackable/trino-server

0 commit comments

Comments
 (0)