Skip to content

Commit 3431707

Browse files
authored
feat: custom version for OPA (#1170)
* feat: support custom product versions * chore: changelog
1 parent ab869d3 commit 3431707

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ All notable changes to this project will be documented in this file.
8282
- vector: Bump to `0.47.0` ([#1152]).
8383
- zookeeper: backport ZOOKEEPER-4846, ZOOKEEPER-4921, ZOOKEEPER-4925 into Zookeeper 3.9.3 ([#1150]).
8484
- testing-tools: Update base image ([#1165]).
85+
- opa: Enable custom versions ([#1170]).
8586

8687
### Fixed
8788

@@ -186,6 +187,7 @@ All notable changes to this project will be documented in this file.
186187
[#1156]: https://github.com/stackabletech/docker-images/pull/1156
187188
[#1163]: https://github.com/stackabletech/docker-images/pull/1163
188189
[#1165]: https://github.com/stackabletech/docker-images/pull/1165
190+
[#1170]: https://github.com/stackabletech/docker-images/pull/1170
189191

190192
## [25.3.0] - 2025-03-21
191193

opa/Dockerfile

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,23 +77,29 @@ go install github.com/CycloneDX/cyclonedx-gomod/cmd/[email protected]
7777

7878
cd "$(/stackable/patchable --images-repo-root=src checkout opa ${PRODUCT})"
7979

80+
ORIGINAL_VERSION=${PRODUCT}
81+
NEW_VERSION="${PRODUCT}-stackable${RELEASE}"
82+
83+
sed -i 's/var Version = "'${ORIGINAL_VERSION}'"/var Version = "'${NEW_VERSION}'"/g' v1/version/version.go
84+
8085
# Create snapshot of the source code including custom patches
81-
tar -czf /stackable/opa-${PRODUCT}-src.tar.gz .
86+
tar -czf /stackable/opa-${NEW_VERSION}-src.tar.gz .
8287

8388
# Unfortunately, we need to create a dummy Git repository to allow cyclonedx-gomod to determine the version of OPA
8489
rm .git
8590
git init
8691
git config user.email "[email protected]"
8792
git config user.name "Fake commiter"
8893
git commit --allow-empty --message "Fake commit, so that we can create a tag"
89-
git tag "v${PRODUCT}"
94+
git tag "v${NEW_VERSION}"
9095
go build -o opa -buildmode=exe
9196
# move artifact to /stackable/*/ to copy in final image
92-
~/go/bin/cyclonedx-gomod app -json -output-version 1.5 -output /stackable/opa/"opa_${PRODUCT}.cdx.json" -packages -files
97+
~/go/bin/cyclonedx-gomod app -json -output-version 1.5 -output /stackable/opa/"opa_${NEW_VERSION}.cdx.json" -packages -files
98+
sed -i "s/${NEW_VERSION}/${ORIGINAL_VERSION}/g" /stackable/opa/"opa_${NEW_VERSION}.cdx.json"
9399
# move artifact to /stackable/* to copy in final image
94100
mv opa /stackable/opa/
95101
# set correct groups
96-
chmod -R g=u /stackable/opa /stackable/opa-${PRODUCT}-src.tar.gz
102+
chmod -R g=u /stackable/opa /stackable/opa-${NEW_VERSION}-src.tar.gz
97103
EOF
98104

99105
FROM stackable/image/vector
@@ -113,7 +119,7 @@ LABEL name="Open Policy Agent" \
113119
COPY --chown=${STACKABLE_USER_UID}:0 opa/licenses /licenses
114120

115121
COPY --from=opa-builder --chown=${STACKABLE_USER_UID}:0 /stackable/opa /stackable/opa
116-
COPY --from=opa-builder --chown=${STACKABLE_USER_UID}:0 /stackable/opa-${PRODUCT}-src.tar.gz /stackable/opa-${PRODUCT}-src.tar.gz
122+
COPY --from=opa-builder --chown=${STACKABLE_USER_UID}:0 /stackable/opa-${PRODUCT}-stackable${RELEASE}-src.tar.gz /stackable/opa-${PRODUCT}-stackable${RELEASE}-src.tar.gz
117123
COPY --from=multilog-builder --chown=${STACKABLE_USER_UID}:0 /daemontools/admin/daemontools/command/multilog /stackable/multilog
118124

119125
RUN <<EOF

0 commit comments

Comments
 (0)