Skip to content

feat: custom version for OPA #1170

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ All notable changes to this project will be documented in this file.
- vector: Bump to `0.47.0` ([#1152]).
- zookeeper: backport ZOOKEEPER-4846, ZOOKEEPER-4921, ZOOKEEPER-4925 into Zookeeper 3.9.3 ([#1150]).
- testing-tools: Update base image ([#1165]).
- opa: Enable custom versions ([#1170]).

### Fixed

Expand Down Expand Up @@ -188,6 +189,7 @@ All notable changes to this project will be documented in this file.
[#1157]: https://github.com/stackabletech/docker-images/pull/1157
[#1163]: https://github.com/stackabletech/docker-images/pull/1163
[#1165]: https://github.com/stackabletech/docker-images/pull/1165
[#1170]: https://github.com/stackabletech/docker-images/pull/1170

## [25.3.0] - 2025-03-21

Expand Down
16 changes: 11 additions & 5 deletions opa/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -77,23 +77,29 @@ go install github.com/CycloneDX/cyclonedx-gomod/cmd/[email protected]

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

ORIGINAL_VERSION=${PRODUCT}
NEW_VERSION="${PRODUCT}-stackable${RELEASE}"

sed -i 's/var Version = "'${ORIGINAL_VERSION}'"/var Version = "'${NEW_VERSION}'"/g' v1/version/version.go

# Create snapshot of the source code including custom patches
tar -czf /stackable/opa-${PRODUCT}-src.tar.gz .
tar -czf /stackable/opa-${NEW_VERSION}-src.tar.gz .

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

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

COPY --from=opa-builder --chown=${STACKABLE_USER_UID}:0 /stackable/opa /stackable/opa
COPY --from=opa-builder --chown=${STACKABLE_USER_UID}:0 /stackable/opa-${PRODUCT}-src.tar.gz /stackable/opa-${PRODUCT}-src.tar.gz
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
COPY --from=multilog-builder --chown=${STACKABLE_USER_UID}:0 /daemontools/admin/daemontools/command/multilog /stackable/multilog

RUN <<EOF
Expand Down