Skip to content

Commit f4f619a

Browse files
committed
Adds Trino
1 parent 6155a94 commit f4f619a

File tree

1 file changed

+69
-44
lines changed

1 file changed

+69
-44
lines changed

trino/Dockerfile

Lines changed: 69 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
FROM stackable/image/java-devel AS storage-connector-builder
55

66
ARG STORAGE_CONNECTOR
7+
ARG STACKABLE_USER_UID
78

89
RUN <<EOF
910
microdnf update
@@ -18,23 +19,28 @@ EOF
1819

1920
WORKDIR /stackable
2021

21-
COPY --chown=stackable:stackable trino/stackable/patches/apply_patches.sh /stackable/trino-storage-${STORAGE_CONNECTOR}-src/patches/apply_patches.sh
22-
COPY --chown=stackable:stackable trino/stackable/patches/trino-storage/${STORAGE_CONNECTOR} /stackable/trino-storage-${STORAGE_CONNECTOR}-src/patches/${STORAGE_CONNECTOR}
22+
COPY --chown=${STACKABLE_USER_UID}:0 trino/stackable/patches/apply_patches.sh /stackable/trino-storage-${STORAGE_CONNECTOR}-src/patches/apply_patches.sh
23+
COPY --chown=${STACKABLE_USER_UID}:0 trino/stackable/patches/trino-storage/${STORAGE_CONNECTOR} /stackable/trino-storage-${STORAGE_CONNECTOR}-src/patches/${STORAGE_CONNECTOR}
2324

2425
RUN curl "https://repo.stackable.tech/repository/packages/trino-storage/trino-storage-${STORAGE_CONNECTOR}-src.tar.gz" | tar -xzC .
2526
# adding a hadolint ignore for SC2215, due to https://github.com/hadolint/hadolint/issues/980
2627
# hadolint ignore=SC2215
27-
RUN --mount=type=cache,target=/root/.m2/repository cd trino-storage-${STORAGE_CONNECTOR}-src && \
28-
./patches/apply_patches.sh ${STORAGE_CONNECTOR} && \
29-
# Upstream builds are marked as -SNAPSHOT, even for release builds
30-
mvn versions:set -DnewVersion=${STORAGE_CONNECTOR} && \
31-
# We need to use ./mvnw instead of mvn to get a recent maven version (which is required to build Trino)
32-
./mvnw package -DskipTests -Dmaven.gitcommitid.skip=true
28+
RUN --mount=type=cache,id=maven-${STORAGE_CONNECTOR},target=/root/.m2/repository <<EOF
29+
cd trino-storage-${STORAGE_CONNECTOR}-src
30+
./patches/apply_patches.sh ${STORAGE_CONNECTOR}
31+
32+
# Upstream builds are marked as -SNAPSHOT, even for release builds
33+
mvn versions:set -DnewVersion=${STORAGE_CONNECTOR}
34+
35+
# We need to use ./mvnw instead of mvn to get a recent maven version (which is required to build Trino)
36+
./mvnw package -DskipTests -Dmaven.gitcommitid.skip=true
37+
EOF
3338

3439
FROM stackable/image/java-devel AS builder
3540

3641
ARG PRODUCT
3742
ARG STORAGE_CONNECTOR
43+
ARG STACKABLE_USER_UID
3844

3945
RUN <<EOF
4046
microdnf update
@@ -51,35 +57,42 @@ WORKDIR /stackable
5157

5258
RUN curl "https://repo.stackable.tech/repository/packages/trino-server/trino-server-${PRODUCT}-src.tar.gz" | tar -xzC .
5359

54-
COPY --chown=stackable:stackable trino/stackable/patches/apply_patches.sh /stackable/trino-server-${PRODUCT}-src/patches/apply_patches.sh
55-
COPY --chown=stackable:stackable trino/stackable/patches/${PRODUCT} /stackable/trino-server-${PRODUCT}-src/patches/${PRODUCT}
60+
COPY --chown=${STACKABLE_USER_UID}:0 trino/stackable/patches/apply_patches.sh /stackable/trino-server-${PRODUCT}-src/patches/apply_patches.sh
61+
COPY --chown=${STACKABLE_USER_UID}:0 trino/stackable/patches/${PRODUCT} /stackable/trino-server-${PRODUCT}-src/patches/${PRODUCT}
5662

5763
# adding a hadolint ignore for SC2215, due to https://github.com/hadolint/hadolint/issues/980
5864
# hadolint ignore=SC2215
59-
RUN --mount=type=cache,target=/root/.m2/repository cd "trino-server-${PRODUCT}-src" && \
60-
./patches/apply_patches.sh ${PRODUCT} && \
61-
# Trino is using something (git-commit-id-plugin in the past, maybe something else now) that is
62-
# reading the Git history and searches for a tag to pull the version from. It sounds weird to me
63-
# why someone would do that over just picking the version from the pom.xml, but they propably
64-
# have their reasons. See e.g. https://github.com/trinodb/trino/discussions/18963.
65-
# So we fake it till we make it and create a Git repo and the correct tag. The trino-operator
66-
# smoke test checks that "select version()" is working.
67-
git init && \
68-
git config user.email "fake.commiter@stackable.tech" && \
69-
git config user.name "Fake commiter" && \
70-
git commit --allow-empty --message "Fake commit, so that we can create a tag" && \
71-
git tag ${PRODUCT} && \
72-
# We need to use ./mvnw instead of mvn to get a recent maven version (which is required to build Trino)
73-
./mvnw package -DskipTests --projects="!docs,!core/trino-server-rpm" && \
74-
# Delete the worst intermediate build products to free some space
75-
rm -r /stackable/trino-server-${PRODUCT}-src/plugin/*/target /stackable/trino-server-${PRODUCT}-src/core/trino-server/target/trino-server-${PRODUCT} && \
76-
# Extract from tarball to save space; the tarball deduplicates jars (replacing them with symlinks),
77-
# while the raw output folder does not
78-
tar -xzf /stackable/trino-server-${PRODUCT}-src/core/trino-server/target/trino-server-${PRODUCT}.tar.gz -C /stackable && \
79-
mv /stackable/trino-server-${PRODUCT}-src/core/trino-server/target/bom.json /stackable/trino-server-${PRODUCT}/trino-server-${PRODUCT}.cdx.json && \
80-
chown --recursive stackable /stackable/trino-server-${PRODUCT} && \
81-
# Delete all intermediate build products to free some more space
82-
rm -r /stackable/trino-server-${PRODUCT}-src
65+
RUN --mount=type=cache,id=maven-${PRODUCT},target=/root/.m2/repository <<EOF
66+
cd "trino-server-${PRODUCT}-src"
67+
./patches/apply_patches.sh ${PRODUCT}
68+
69+
# Trino is using something (git-commit-id-plugin in the past, maybe something else now) that is
70+
# reading the Git history and searches for a tag to pull the version from. It sounds weird to me
71+
# why someone would do that over just picking the version from the pom.xml, but they propably
72+
# have their reasons. See e.g. https://github.com/trinodb/trino/discussions/18963.
73+
# So we fake it till we make it and create a Git repo and the correct tag. The trino-operator
74+
# smoke test checks that "select version()" is working.
75+
git init
76+
git config user.email "fake.commiter@stackable.tech"
77+
git config user.name "Fake commiter"
78+
git commit --allow-empty --message "Fake commit, so that we can create a tag"
79+
git tag ${PRODUCT}
80+
81+
# We need to use ./mvnw instead of mvn to get a recent maven version (which is required to build Trino)
82+
./mvnw package -DskipTests --projects="!docs,!core/trino-server-rpm"
83+
84+
# Delete the worst intermediate build products to free some space
85+
rm -r /stackable/trino-server-${PRODUCT}-src/plugin/*/target /stackable/trino-server-${PRODUCT}-src/core/trino-server/target/trino-server-${PRODUCT}
86+
87+
# Extract from tarball to save space; the tarball deduplicates jars (replacing them with symlinks),
88+
# while the raw output folder does not
89+
tar -xzf /stackable/trino-server-${PRODUCT}-src/core/trino-server/target/trino-server-${PRODUCT}.tar.gz -C /stackable
90+
mv /stackable/trino-server-${PRODUCT}-src/core/trino-server/target/bom.json /stackable/trino-server-${PRODUCT}/trino-server-${PRODUCT}.cdx.json
91+
chown --recursive ${STACKABLE_USER_UID}:0 /stackable/trino-server-${PRODUCT}
92+
93+
# Delete all intermediate build products to free some more space
94+
rm -r /stackable/trino-server-${PRODUCT}-src
95+
EOF
8396

8497
COPY --from=storage-connector-builder /stackable/trino-storage-${STORAGE_CONNECTOR}-src/target/trino-storage-${STORAGE_CONNECTOR} /stackable/trino-server-${PRODUCT}/plugin/trino-storage-${STORAGE_CONNECTOR}
8598

@@ -103,6 +116,7 @@ RUN /bin/log4shell_scanner s /stackable/trino-server-${PRODUCT}
103116
FROM stackable/image/java-devel AS jmx-exporter-builder
104117

105118
ARG JMX_EXPORTER
119+
ARG STACKABLE_USER_UID
106120

107121
RUN <<EOF
108122
microdnf update
@@ -117,21 +131,24 @@ EOF
117131

118132
WORKDIR /stackable
119133

120-
COPY --chown=stackable:stackable trino/stackable/patches/apply_patches.sh /stackable/jmx_prometheus-${JMX_EXPORTER}-src/patches/apply_patches.sh
121-
COPY --chown=stackable:stackable trino/stackable/patches/jmx-exporter/${JMX_EXPORTER} /stackable/jmx_prometheus-${JMX_EXPORTER}-src/patches/${JMX_EXPORTER}
134+
COPY --chown=${STACKABLE_USER_UID}:0 trino/stackable/patches/apply_patches.sh /stackable/jmx_prometheus-${JMX_EXPORTER}-src/patches/apply_patches.sh
135+
COPY --chown=${STACKABLE_USER_UID}:0 trino/stackable/patches/jmx-exporter/${JMX_EXPORTER} /stackable/jmx_prometheus-${JMX_EXPORTER}-src/patches/${JMX_EXPORTER}
122136

123137
RUN curl "https://repo.stackable.tech/repository/packages/jmx-exporter/jmx_prometheus-${JMX_EXPORTER}-src.tar.gz" | tar -xzC .
124138
# adding a hadolint ignore for SC2215, due to https://github.com/hadolint/hadolint/issues/980
125139
# hadolint ignore=SC2215
126-
RUN --mount=type=cache,target=/root/.m2/repository cd jmx_prometheus-${JMX_EXPORTER}-src && \
127-
./patches/apply_patches.sh ${JMX_EXPORTER} && \
128-
mvn package
140+
RUN --mount=type=cache,id=maven-${JMX_EXPORTER},target=/root/.m2/repository <<EOF
141+
cd jmx_prometheus-${JMX_EXPORTER}-src
142+
./patches/apply_patches.sh ${JMX_EXPORTER}
143+
mvn package
144+
EOF
129145

130146
FROM stackable/image/java-base
131147

132148
ARG PRODUCT
133149
ARG JMX_EXPORTER
134150
ARG RELEASE
151+
ARG STACKABLE_USER_UID
135152

136153
LABEL name="Trino" \
137154
maintainer="info@stackable.tech" \
@@ -151,16 +168,24 @@ RUN microdnf update && \
151168
microdnf clean all && \
152169
rm -rf /var/cache/yum
153170

154-
USER stackable
155171
WORKDIR /stackable
156172

157-
COPY --chown=stackable:stackable trino/stackable /stackable
158-
COPY --chown=stackable:stackable trino/licenses /licenses
173+
COPY --chown=${STACKABLE_USER_UID}:0 trino/stackable /stackable
174+
COPY --chown=${STACKABLE_USER_UID}:0 trino/licenses /licenses
159175

160176
COPY --from=builder /stackable/trino-server-${PRODUCT} /stackable/trino-server-${PRODUCT}
161177
COPY --from=jmx-exporter-builder /stackable/jmx_prometheus-${JMX_EXPORTER}-src/jmx_prometheus_javaagent/target/jmx_prometheus_javaagent-${JMX_EXPORTER}.jar /stackable/jmx/jmx_prometheus_javaagent-${JMX_EXPORTER}.jar
162-
RUN ln -s /stackable/trino-server-${PRODUCT} /stackable/trino-server && \
163-
ln -s /stackable/jmx/jmx_prometheus_javaagent-${JMX_EXPORTER}.jar /stackable/jmx/jmx_prometheus_javaagent.jar
164178

179+
RUN <<EOF
180+
ln -s /stackable/trino-server-${PRODUCT} /stackable/trino-server
181+
ln -s /stackable/jmx/jmx_prometheus_javaagent-${JMX_EXPORTER}.jar /stackable/jmx/jmx_prometheus_javaagent.jar
182+
183+
# All files and folders owned by root group to support running as arbitrary users.
184+
# This is best practice as all container users will belong to the root group (0).
185+
chown -R ${STACKABLE_USER_UID}:0 /stackable
186+
chmod -R g=u /stackable
187+
EOF
188+
189+
USER ${STACKABLE_USER_UID}
165190
WORKDIR /stackable/trino-server
166191
CMD ["bin/launcher", "run", "--etc-dir=/stackable/conf"]

0 commit comments

Comments
 (0)