@@ -25,8 +25,8 @@ microdnf update
25
25
#
26
26
# patch: Required for the apply-patches.sh script
27
27
microdnf install \
28
- python-pyyaml \
29
- patch
28
+ python-pyyaml \
29
+ patch
30
30
31
31
microdnf clean all
32
32
rm -rf /var/cache/yum
@@ -47,9 +47,9 @@ COPY --chown=stackable:0 druid/stackable/patches/${PRODUCT} /stackable/apache-dr
47
47
# are still working in the cache directory.
48
48
49
49
RUN --mount=type=cache,id=maven-${PRODUCT},uid=${STACKABLE_USER_UID},target=/stackable/.m2/repository \
50
- --mount=type=cache,id=npm-${PRODUCT},uid=${STACKABLE_USER_UID},target=/stackable/.npm \
51
- --mount=type=cache,id=cache-${PRODUCT},uid=${STACKABLE_USER_UID},target=/stackable/.cache \
52
- <<EOF
50
+ --mount=type=cache,id=npm-${PRODUCT},uid=${STACKABLE_USER_UID},target=/stackable/.npm \
51
+ --mount=type=cache,id=cache-${PRODUCT},uid=${STACKABLE_USER_UID},target=/stackable/.cache \
52
+ <<EOF
53
53
curl "https://repo.stackable.tech/repository/packages/druid/apache-druid-${PRODUCT}-src.tar.gz" | tar -xzC .
54
54
cd apache-druid-${PRODUCT}-src
55
55
./patches/apply_patches.sh ${PRODUCT}
74
74
75
75
# Install OPA authorizer extension.
76
76
curl "https://repo.stackable.tech/repository/packages/druid/druid-opa-authorizer-${AUTHORIZER}.tar.gz" | tar -xzC /stackable/apache-druid-${PRODUCT}/extensions
77
+
78
+ # change groups
79
+ chmod -R g=u /stackable
77
80
EOF
78
81
79
82
FROM stackable/image/java-base AS final
@@ -106,32 +109,45 @@ LABEL io.k8s.display-name="${NAME}"
106
109
107
110
108
111
COPY --chown=${STACKABLE_USER_UID}:0 --from=druid-builder /stackable/apache-druid-${PRODUCT} /stackable/apache-druid-${PRODUCT}
112
+
109
113
COPY --chown=${STACKABLE_USER_UID}:0 druid/stackable/bin /stackable/bin
110
114
COPY --chown=${STACKABLE_USER_UID}:0 druid/licenses /licenses
111
115
112
116
RUN <<EOF
113
117
microdnf update
114
118
microdnf clean all
115
119
rpm -qa --qf "%{NAME}-%{VERSION}-%{RELEASE}\n " | sort > /stackable/package_manifest.txt
120
+ chown ${STACKABLE_USER_UID}:0 /stackable/package_manifest.txt
121
+ chmod g=u /stackable/package_manifest.txt
116
122
rm -rf /var/cache/yum
117
123
118
- ln -s /stackable/apache-druid-${PRODUCT} /stackable/druid
124
+ ln -sf /stackable/apache-druid-${PRODUCT} /stackable/druid
125
+ chown -h ${STACKABLE_USER_UID}:0 stackable/druid
119
126
120
127
# Force to overwrite the existing 'run-druid'
121
128
ln -sf /stackable/bin/run-druid /stackable/druid/bin/run-druid
129
+ chown -h ${STACKABLE_USER_UID}:0 /stackable/druid/bin/run-druid
122
130
123
- # All files and folders owned by root group to support running as arbitrary users.
124
- # This is best practice as all container users will belong to the root group (0).
125
- chown -R ${STACKABLE_USER_UID}:0 /stackable
126
- chmod -R g=u /stackable
131
+ # fix missing permissions
132
+ chmod -R g=u /stackable/bin
133
+ chmod g=u /stackable/apache-druid-${PRODUCT}
127
134
EOF
128
135
129
136
# ----------------------------------------
130
- # Attention: We are changing the group of all files in /stackable directly above
131
- # If you do any file based actions (copying / creating etc.) below this comment you
132
- # absolutely need to make sure that the correct permissions are applied!
133
- # chown ${STACKABLE_USER_UID}:0
137
+ # Checks
138
+ # This section is to run final checks to ensure the created final images
139
+ # adhere to several minimal requirements like:
140
+ # - check file permissions and ownerships
141
+ # ----------------------------------------
142
+
143
+ # Check that permissions and ownership in /stackable are set correctly
144
+ # This will fail and stop the build if any mismatches are found.
145
+ RUN <<EOF
146
+ /bin/check-permissions-ownership.sh /stackable ${STACKABLE_USER_UID} 0
147
+ EOF
148
+
134
149
# ----------------------------------------
150
+ # Attention: Do not perform any file based actions (copying/creating etc.) below this comment because the permissions would not be checked.
135
151
136
152
USER ${STACKABLE_USER_UID}
137
153
ENV PATH="${PATH}" :/stackable/druid/bin
0 commit comments