4
4
FROM stackable/image/java-devel AS storage-connector-builder
5
5
6
6
ARG STORAGE_CONNECTOR
7
+ ARG STACKABLE_USER_UID
7
8
8
9
RUN <<EOF
9
10
microdnf update
18
19
19
20
WORKDIR /stackable
20
21
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}
23
24
24
25
RUN curl "https://repo.stackable.tech/repository/packages/trino-storage/trino-storage-${STORAGE_CONNECTOR}-src.tar.gz" | tar -xzC .
25
26
# adding a hadolint ignore for SC2215, due to https://github.com/hadolint/hadolint/issues/980
26
27
# 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
33
38
34
39
FROM stackable/image/java-devel AS builder
35
40
36
41
ARG PRODUCT
37
42
ARG STORAGE_CONNECTOR
43
+ ARG STACKABLE_USER_UID
38
44
39
45
RUN <<EOF
40
46
microdnf update
@@ -51,35 +57,42 @@ WORKDIR /stackable
51
57
52
58
RUN curl "https://repo.stackable.tech/repository/packages/trino-server/trino-server-${PRODUCT}-src.tar.gz" | tar -xzC .
53
59
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}
56
62
57
63
# adding a hadolint ignore for SC2215, due to https://github.com/hadolint/hadolint/issues/980
58
64
# 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
83
96
84
97
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}
85
98
@@ -103,6 +116,7 @@ RUN /bin/log4shell_scanner s /stackable/trino-server-${PRODUCT}
103
116
FROM stackable/image/java-devel AS jmx-exporter-builder
104
117
105
118
ARG JMX_EXPORTER
119
+ ARG STACKABLE_USER_UID
106
120
107
121
RUN <<EOF
108
122
microdnf update
@@ -117,21 +131,24 @@ EOF
117
131
118
132
WORKDIR /stackable
119
133
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}
122
136
123
137
RUN curl "https://repo.stackable.tech/repository/packages/jmx-exporter/jmx_prometheus-${JMX_EXPORTER}-src.tar.gz" | tar -xzC .
124
138
# adding a hadolint ignore for SC2215, due to https://github.com/hadolint/hadolint/issues/980
125
139
# 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
129
145
130
146
FROM stackable/image/java-base
131
147
132
148
ARG PRODUCT
133
149
ARG JMX_EXPORTER
134
150
ARG RELEASE
151
+ ARG STACKABLE_USER_UID
135
152
136
153
LABEL name="Trino" \
137
154
maintainer="info@stackable.tech" \
@@ -151,16 +168,24 @@ RUN microdnf update && \
151
168
microdnf clean all && \
152
169
rm -rf /var/cache/yum
153
170
154
- USER stackable
155
171
WORKDIR /stackable
156
172
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
159
175
160
176
COPY --from=builder /stackable/trino-server-${PRODUCT} /stackable/trino-server-${PRODUCT}
161
177
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
164
178
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}
165
190
WORKDIR /stackable/trino-server
166
191
CMD ["bin/launcher" , "run" , "--etc-dir=/stackable/conf" ]
0 commit comments