Skip to content

Commit dbdbf02

Browse files
Make the notary version detectable
1 parent d1a94cf commit dbdbf02

File tree

7 files changed

+13
-31
lines changed

7 files changed

+13
-31
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
.jq-template.awk
2-
.template-helper-functions.jq

Dockerfile-builder.template

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
{{ include ".template-helper-functions" -}}
21
FROM golang:1.19-alpine{{ .alpine }}
32

43
RUN apk add --no-cache git make
@@ -11,28 +10,18 @@ ENV GOFLAGS -mod=vendor
1110
WORKDIR /go/src/$NOTARYPKG
1211
RUN set -eux; \
1312
git clone -b "$TAG" --depth 1 "https://$NOTARYPKG.git" .; \
13+
# In case the version in file doens't match the tag (like in 0.7.0)
14+
echo "${TAG//v/}" > NOTARY_VERSION; \
1415
# https://github.com/notaryproject/notary/pull/1635
1516
git fetch --depth 2 origin efc35b02698644af16f6049c7b585697352451b8; \
1617
git -c user.name=foo -c user.email=foo@example.com cherry-pick -x efc35b02698644af16f6049c7b585697352451b8; \
1718
# https://github.com/notaryproject/notary/issues/1602 (rough cherry-pick of ca095023296d2d710ad9c6dec019397d46bf8576)
1819
go get github.com/dvsekhvalnov/jose2go@v0.0.0-20200901110807-248326c1351b; \
1920
go mod vendor; \
2021
# TODO remove for the next release of Notary (which should include efc35b02698644af16f6049c7b585697352451b8 & ca095023296d2d710ad9c6dec019397d46bf8576)
22+
# Make the version detectable by scanners
23+
sed -i -r -E 's|(version.NotaryVersion=\$\(NOTARY_VERSION\))|\1 -X $(NOTARY_PKG)/version.Version=$(NOTARY_VERSION)|' Makefile; \
2124
make SKIPENVCHECK=1 PREFIX=. ./bin/static/notary-server ./bin/static/notary-signer; \
2225
cp -vL ./bin/static/notary-server ./bin/static/notary-signer /; \
2326
/notary-server --version; \
24-
/notary-signer --version; \
25-
\
26-
echo {{
27-
{
28-
name: "notary",
29-
version: .version,
30-
params: {
31-
os_name: "alpine",
32-
os_version: .alpine
33-
},
34-
licenses: [
35-
"Apache-2.0"
36-
]
37-
} | sbom | tostring | @sh
38-
}} > /notary.spdx.json;
27+
/notary-signer --version;

Dockerfile.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ ENV INSTALLDIR /notary/{{ env.variant }}
1212
ENV PATH=$PATH:${INSTALLDIR}
1313
WORKDIR ${INSTALLDIR}
1414

15-
COPY --from=notary:{{ .version }}-builder /notary-{{ env.variant }} /notary.spdx.json ./
15+
COPY --from=notary:{{ .version }}-builder /notary-{{ env.variant }} ./
1616
RUN ./notary-{{ env.variant }} --version
1717

1818
COPY ./{{ env.variant }}-config.json .

apply-templates.sh

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,6 @@ elif [ "$BASH_SOURCE" -nt "$jqt" ]; then
1313
wget -qO "$jqt" 'https://github.com/docker-library/bashbrew/raw/9f6a35772ac863a0241f147c820354e4008edf38/scripts/jq-template.awk'
1414
fi
1515

16-
jqf='.template-helper-functions.jq'
17-
if [ -n "${BASHBREW_SCRIPTS:-}" ]; then
18-
jqf="$BASHBREW_SCRIPTS/template-helper-functions.jq"
19-
elif [ "$BASH_SOURCE" -nt "$jqf" ]; then
20-
wget -qO "$jqf" 'https://github.com/docker-library/bashbrew/raw/master/scripts/template-helper-functions.jq'
21-
fi
22-
23-
2416
generated_warning() {
2517
cat <<-EOH
2618
#

notary-builder/Dockerfile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,18 @@ ENV GOFLAGS -mod=vendor
1616
WORKDIR /go/src/$NOTARYPKG
1717
RUN set -eux; \
1818
git clone -b "$TAG" --depth 1 "https://$NOTARYPKG.git" .; \
19+
# In case the version in file doens't match the tag (like in 0.7.0)
20+
echo "${TAG//v/}" > NOTARY_VERSION; \
1921
# https://github.com/notaryproject/notary/pull/1635
2022
git fetch --depth 2 origin efc35b02698644af16f6049c7b585697352451b8; \
2123
git -c user.name=foo -c user.email=foo@example.com cherry-pick -x efc35b02698644af16f6049c7b585697352451b8; \
2224
# https://github.com/notaryproject/notary/issues/1602 (rough cherry-pick of ca095023296d2d710ad9c6dec019397d46bf8576)
2325
go get github.com/dvsekhvalnov/jose2go@v0.0.0-20200901110807-248326c1351b; \
2426
go mod vendor; \
2527
# TODO remove for the next release of Notary (which should include efc35b02698644af16f6049c7b585697352451b8 & ca095023296d2d710ad9c6dec019397d46bf8576)
28+
# Make the version detectable by scanners
29+
sed -i -r -E 's|(version.NotaryVersion=\$\(NOTARY_VERSION\))|\1 -X $(NOTARY_PKG)/version.Version=$(NOTARY_VERSION)|' Makefile; \
2630
make SKIPENVCHECK=1 PREFIX=. ./bin/static/notary-server ./bin/static/notary-signer; \
2731
cp -vL ./bin/static/notary-server ./bin/static/notary-signer /; \
2832
/notary-server --version; \
29-
/notary-signer --version; \
30-
\
31-
echo '{"spdxVersion":"SPDX-2.3","SPDXID":"SPDXRef-DOCUMENT","name":"notary-sbom","packages":[{"name":"notary","versionInfo":"0.7.0","SPDXID":"SPDXRef-Package--notary","externalRefs":[{"referenceCategory":"PACKAGE-MANAGER","referenceType":"purl","referenceLocator":"pkg:generic/notary@0.7.0?os_name=alpine&os_version=3.16"}],"licenseDeclared":"Apache-2.0"}]}' > /notary.spdx.json;
33+
/notary-signer --version;

notary-server/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ ENV INSTALLDIR /notary/server
1313
ENV PATH=$PATH:${INSTALLDIR}
1414
WORKDIR ${INSTALLDIR}
1515

16-
COPY --from=notary:0.7.0-builder /notary-server /notary.spdx.json ./
16+
COPY --from=notary:0.7.0-builder /notary-server ./
1717
RUN ./notary-server --version
1818

1919
COPY ./server-config.json .

notary-signer/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ ENV INSTALLDIR /notary/signer
1414
ENV PATH=$PATH:${INSTALLDIR}
1515
WORKDIR ${INSTALLDIR}
1616

17-
COPY --from=notary:0.7.0-builder /notary-signer /notary.spdx.json ./
17+
COPY --from=notary:0.7.0-builder /notary-signer ./
1818
RUN ./notary-signer --version
1919

2020
COPY ./signer-config.json .

0 commit comments

Comments
 (0)