@@ -25,8 +25,8 @@ microdnf update
2525# 
2626#  patch: Required for the apply-patches.sh script
2727microdnf install \
28- python-pyyaml \
29- patch
28+    python-pyyaml \
29+    patch
3030
3131microdnf clean all
3232rm -rf /var/cache/yum
@@ -47,9 +47,9 @@ COPY --chown=stackable:0 druid/stackable/patches/${PRODUCT} /stackable/apache-dr
4747#  are still working in the cache directory.
4848
4949RUN  --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
5353curl "https://repo.stackable.tech/repository/packages/druid/apache-druid-${PRODUCT}-src.tar.gz"  | tar -xzC .
5454cd apache-druid-${PRODUCT}-src
5555./patches/apply_patches.sh ${PRODUCT}
7474
7575#  Install OPA authorizer extension.
7676curl "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
7780EOF
7881
7982FROM  stackable/image/java-base AS final
@@ -106,32 +109,45 @@ LABEL io.k8s.display-name="${NAME}"
106109
107110
108111COPY  --chown=${STACKABLE_USER_UID}:0 --from=druid-builder /stackable/apache-druid-${PRODUCT} /stackable/apache-druid-${PRODUCT}
112+ 
109113COPY  --chown=${STACKABLE_USER_UID}:0 druid/stackable/bin /stackable/bin
110114COPY  --chown=${STACKABLE_USER_UID}:0 druid/licenses /licenses
111115
112116RUN  <<EOF
113117microdnf update
114118microdnf clean all
115119rpm -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
116122rm -rf /var/cache/yum
117123
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
119126
120127#  Force to overwrite the existing 'run-druid'
121128ln -sf /stackable/bin/run-druid /stackable/druid/bin/run-druid
129+ chown -h ${STACKABLE_USER_UID}:0 /stackable/druid/bin/run-druid
122130
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}
127134EOF
128135
129136#  ----------------------------------------
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+ 
134149#  ----------------------------------------
150+ #  Attention: Do not perform any file based actions (copying/creating etc.) below this comment because the permissions would not be checked.
135151
136152USER  ${STACKABLE_USER_UID}
137153ENV  PATH="${PATH}" :/stackable/druid/bin
0 commit comments