@@ -29,6 +29,8 @@ cd ./opa-bundle-builder
2929. "$HOME/.cargo/env"
3030rustup toolchain install
3131cargo --quiet build --release
32+ # set correct groups
33+ chmod -R g=u /opa-bundle-builder/target/release/
3234EOF
3335
3436FROM stackable/image/stackable-base AS multilog-builder
@@ -58,12 +60,15 @@ RUN patch < /daemontools/conf-cc.patch && \
5860
5961WORKDIR /daemontools/admin/daemontools-${DAEMONTOOLS_VERSION}
6062
61- RUN package/install
63+ RUN package/install && \
64+ # set correct groups
65+ chmod g=u /daemontools/admin/daemontools/command/multilog
6266
6367FROM stackable/image/stackable-base AS opa-builder
6468
6569ARG PRODUCT
6670ARG RELEASE
71+ ARG STACKABLE_USER_UID
6772ARG TARGETARCH
6873ARG TARGETOS
6974
@@ -81,11 +86,15 @@ RUN microdnf update && \
8186 tar && \
8287 microdnf clean all
8388
89+ COPY --chown=${STACKABLE_USER_UID}:0 opa/stackable/bin /stackable/opa/bin
90+
91+ RUN <<EOF
8492# We use version 1.7.0, since a newer version of cyclonedx-gomod is not compatible with the version of Golang (>= 1.23.1)
85- RUN go install github.com/CycloneDX/cyclonedx-gomod/cmd/
[email protected] 86- RUN curl "https://repo.stackable.tech/repository/packages/opa/opa_${PRODUCT}.tar.gz" -o opa.tar.gz && \
87- tar -zxvf opa.tar.gz && \
88- mv "opa-${PRODUCT}" opa
93+ go install github.com/CycloneDX/cyclonedx-gomod/cmd/
[email protected] 94+ curl "https://repo.stackable.tech/repository/packages/opa/opa_${PRODUCT}.tar.gz" -o opa.tar.gz
95+ tar -zxvf opa.tar.gz
96+ mv "opa-${PRODUCT}" opa
97+ EOF
8998
9099WORKDIR /opa
91100
@@ -97,7 +106,12 @@ git config user.name "Fake commiter"
97106git commit --allow-empty --message "Fake commit, so that we can create a tag"
98107git tag "v${PRODUCT}"
99108go build -o opa -buildmode=exe
100- ~/go/bin/cyclonedx-gomod app -json -output-version 1.5 -output "opa_${PRODUCT}.cdx.json" -packages -files
109+ # move artifact to /stackable/*/ to copy in final image
110+ ~/go/bin/cyclonedx-gomod app -json -output-version 1.5 -output /stackable/opa/"opa_${PRODUCT}.cdx.json" -packages -files
111+ # move artifact to /stackable/* to copy in final image
112+ mv /opa/opa /stackable/opa/
113+ # set correct groups
114+ chmod -R g=u /stackable/opa
101115EOF
102116
103117FROM stackable/image/vector
@@ -114,32 +128,23 @@ LABEL name="Open Policy Agent" \
114128 summary="The Stackable image for Open Policy Agent (OPA)." \
115129 description="This image is deployed by the Stackable Operator for OPA."
116130
117- COPY opa/licenses /licenses
131+ COPY --chown=${STACKABLE_USER_UID}:0 opa/licenses /licenses
118132
119- COPY --from=opa-builder --chown=${STACKABLE_USER_UID}:0 /opa/opa /stackable/opa/opa
120- COPY --from=opa-builder --chown=${STACKABLE_USER_UID}:0 /opa/opa_${PRODUCT}.cdx.json /stackable/opa/
133+ COPY --from=opa-builder --chown=${STACKABLE_USER_UID}:0 /stackable/opa /stackable/opa
121134COPY --from=opa-bundle-builder --chown=${STACKABLE_USER_UID}:0 /opa-bundle-builder/target/release/stackable-opa-bundle-builder /stackable/opa-bundle-builder
122135COPY --from=multilog-builder --chown=${STACKABLE_USER_UID}:0 /daemontools/admin/daemontools/command/multilog /stackable/multilog
123136
124- COPY --chown=${STACKABLE_USER_UID}:0 opa/stackable/bin /stackable/opa/bin
125-
126137RUN <<EOF
127138microdnf update
128-
129139# jq: Required for filtering logs
130140microdnf install \
131141 jq
132142microdnf clean all
133143rm -rf /var/cache/yum
134-
135- # All files and folders owned by root group to support running as arbitrary users.
136- # This is best practice as all container users will belong to the root group (0).
137- chown -R ${STACKABLE_USER_UID}:0 /stackable
138- chmod -R g=u /stackable
139144EOF
140145
141146# ----------------------------------------
142- # Attention: We are changing the group of all files in /stackable directly above
147+ # Attention:
143148# If you do any file based actions (copying / creating etc.) below this comment you
144149# absolutely need to make sure that the correct permissions are applied!
145150# chown ${STACKABLE_USER_UID}:0
0 commit comments