@@ -6,18 +6,20 @@ FROM stackable/image/stackable-base AS opa-bundle-builder
6
6
ARG BUNDLE_BUILDER_VERSION
7
7
8
8
# Update image and install everything needed for Rustup & Rust
9
- RUN microdnf update \
10
- && microdnf install \
11
- cmake \
12
- gcc \
13
- gcc-c++ \
14
- git \
15
- make \
16
- openssl-devel \
17
- pkg-config \
18
- systemd-devel \
19
- unzip \
20
- && rm -rf /var/cache/yum
9
+ RUN <<EOF
10
+ microdnf update
11
+ microdnf install \
12
+ cmake \
13
+ gcc \
14
+ gcc-c++ \
15
+ git \
16
+ make \
17
+ openssl-devel \
18
+ pkg-config \
19
+ systemd-devel \
20
+ unzip
21
+ rm -rf /var/cache/yum
22
+ EOF
21
23
22
24
WORKDIR /
23
25
@@ -29,6 +31,8 @@ cd ./opa-bundle-builder
29
31
. "$HOME/.cargo/env"
30
32
rustup toolchain install
31
33
cargo --quiet build --release
34
+ # set correct groups
35
+ chmod -R g=u /opa-bundle-builder/target/release/
32
36
EOF
33
37
34
38
FROM stackable/image/stackable-base AS multilog-builder
@@ -37,33 +41,38 @@ ARG DAEMONTOOLS_VERSION=0.76
37
41
38
42
COPY opa/daemontools /daemontools
39
43
40
- RUN microdnf update && \
41
- microdnf install \
42
- gcc \
43
- gzip \
44
- make \
45
- patch \
46
- tar && \
47
- microdnf clean all \
48
- && rm -rf /var/cache/yum
49
-
50
- WORKDIR /daemontools
51
-
52
- RUN tar xzf daemontools-${DAEMONTOOLS_VERSION}.tar.gz
44
+ RUN <<EOF
45
+ microdnf update
46
+ microdnf install \
47
+ gcc \
48
+ gzip \
49
+ make \
50
+ patch \
51
+ tar
52
+ microdnf clean all
53
+ rm -rf /var/cache/yum
54
+ EOF
53
55
54
- WORKDIR /daemontools/admin/daemontools-${DAEMONTOOLS_VERSION}/src
56
+ RUN <<EOF
57
+ cd /daemontools
58
+ tar xzf daemontools-${DAEMONTOOLS_VERSION}.tar.gz
55
59
56
- RUN patch < /daemontools/conf-cc.patch && \
57
- patch multilog.c < /daemontools/multilog_max_file_size.patch
60
+ cd /daemontools/admin/daemontools-${DAEMONTOOLS_VERSION}/src
61
+ patch < /daemontools/conf-cc.patch
62
+ patch multilog.c < /daemontools/multilog_max_file_size.patch
58
63
59
- WORKDIR /daemontools/admin/daemontools-${DAEMONTOOLS_VERSION}
64
+ cd /daemontools/admin/daemontools-${DAEMONTOOLS_VERSION}
65
+ package/install
60
66
61
- RUN package/install
67
+ # set correct groups
68
+ chmod g=u /daemontools/admin/daemontools/command/multilog
69
+ EOF
62
70
63
71
FROM stackable/image/stackable-base AS opa-builder
64
72
65
73
ARG PRODUCT
66
74
ARG RELEASE
75
+ ARG STACKABLE_USER_UID
67
76
ARG TARGETARCH
68
77
ARG TARGETOS
69
78
@@ -73,19 +82,25 @@ ENV GOOS=$TARGETOS
73
82
# gzip, tar - used to unpack the OPA source
74
83
# git - needed by the cyclonedx-gomod tool to determine the version of OPA
75
84
# golang - used to build OPA
76
- RUN microdnf update && \
77
- microdnf install \
78
- git \
79
- golang \
80
- gzip \
81
- tar && \
82
- microdnf clean all
85
+ RUN <<EOF
86
+ microdnf update
87
+ microdnf install \
88
+ git \
89
+ golang \
90
+ gzip \
91
+ tar
92
+ microdnf clean all
93
+ EOF
83
94
95
+ COPY --chown=${STACKABLE_USER_UID}:0 opa/stackable/bin /stackable/opa/bin
96
+
97
+ RUN <<EOF
84
98
# 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
99
+ go install github.com/CycloneDX/cyclonedx-gomod/cmd/
[email protected]
100
+ curl "https://repo.stackable.tech/repository/packages/opa/opa_${PRODUCT}.tar.gz" -o opa.tar.gz
101
+ tar -zxvf opa.tar.gz
102
+ mv "opa-${PRODUCT}" opa
103
+ EOF
89
104
90
105
WORKDIR /opa
91
106
@@ -97,7 +112,12 @@ git config user.name "Fake commiter"
97
112
git commit --allow-empty --message "Fake commit, so that we can create a tag"
98
113
git tag "v${PRODUCT}"
99
114
go build -o opa -buildmode=exe
100
- ~/go/bin/cyclonedx-gomod app -json -output-version 1.5 -output "opa_${PRODUCT}.cdx.json" -packages -files
115
+ # move artifact to /stackable/*/ to copy in final image
116
+ ~/go/bin/cyclonedx-gomod app -json -output-version 1.5 -output /stackable/opa/"opa_${PRODUCT}.cdx.json" -packages -files
117
+ # move artifact to /stackable/* to copy in final image
118
+ mv /opa/opa /stackable/opa/
119
+ # set correct groups
120
+ chmod -R g=u /stackable/opa
101
121
EOF
102
122
103
123
FROM stackable/image/vector
@@ -107,43 +127,46 @@ ARG RELEASE
107
127
ARG STACKABLE_USER_UID
108
128
109
129
LABEL name="Open Policy Agent" \
110
-
111
- vendor="Stackable GmbH" \
112
- version="${PRODUCT}" \
113
- release="${RELEASE}" \
114
- summary="The Stackable image for Open Policy Agent (OPA)." \
115
- description="This image is deployed by the Stackable Operator for OPA."
130
+
131
+ vendor="Stackable GmbH" \
132
+ version="${PRODUCT}" \
133
+ release="${RELEASE}" \
134
+ summary="The Stackable image for Open Policy Agent (OPA)." \
135
+ description="This image is deployed by the Stackable Operator for OPA."
116
136
117
- COPY opa/licenses /licenses
137
+ COPY --chown=${STACKABLE_USER_UID}:0 opa/licenses /licenses
118
138
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/
139
+ COPY --from=opa-builder --chown=${STACKABLE_USER_UID}:0 /stackable/opa /stackable/opa
121
140
COPY --from=opa-bundle-builder --chown=${STACKABLE_USER_UID}:0 /opa-bundle-builder/target/release/stackable-opa-bundle-builder /stackable/opa-bundle-builder
122
141
COPY --from=multilog-builder --chown=${STACKABLE_USER_UID}:0 /daemontools/admin/daemontools/command/multilog /stackable/multilog
123
142
124
- COPY --chown=${STACKABLE_USER_UID}:0 opa/stackable/bin /stackable/opa/bin
125
-
126
143
RUN <<EOF
127
144
microdnf update
128
-
129
145
# jq: Required for filtering logs
130
146
microdnf install \
131
147
jq
132
148
microdnf clean all
133
149
rm -rf /var/cache/yum
134
150
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
151
+ # fix missing permissions
152
+ chmod g=u /stackable/opa
139
153
EOF
140
154
141
155
# ----------------------------------------
142
- # Attention: We are changing the group of all files in /stackable directly above
143
- # If you do any file based actions (copying / creating etc.) below this comment you
144
- # absolutely need to make sure that the correct permissions are applied!
145
- # chown ${STACKABLE_USER_UID}:0
156
+ # Checks
157
+ # This section is to run final checks to ensure the created final images
158
+ # adhere to several minimal requirements like:
159
+ # - check file permissions and ownerships
160
+ # ----------------------------------------
161
+
162
+ # Check that permissions and ownership in /stackable are set correctly
163
+ # This will fail and stop the build if any mismatches are found.
164
+ RUN <<EOF
165
+ /bin/check-permissions-ownership.sh /stackable ${STACKABLE_USER_UID} 0
166
+ EOF
167
+
146
168
# ----------------------------------------
169
+ # Attention: Do not perform any file based actions (copying/creating etc.) below this comment because the permissions would not be checked.
147
170
148
171
USER ${STACKABLE_USER_UID}
149
172
WORKDIR /stackable/opa
0 commit comments