Skip to content

Commit 8e4ee23

Browse files
committed
feat: support custom product versions
1 parent fcdb3dc commit 8e4ee23

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

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)