Skip to content

Commit ae7d2ef

Browse files
author
downstream-sync
committed
Apply Red Hat specific modifications
Signed-off-by: downstream-sync <[email protected]>
1 parent 6f54d8f commit ae7d2ef

File tree

3 files changed

+67
-19
lines changed

3 files changed

+67
-19
lines changed

.syft/config.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
exclude:
2+
- "**/test-fixtures"

Dockerfile

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,43 @@
1-
FROM gcr.io/distroless/static-debian11:debug@sha256:a0a404776dec98be120089ae42bbdfbe48c177921d856937d124d48eb8c0b951 AS build
1+
FROM brew.registry.redhat.io/rh-osbs/openshift-golang-builder:v1.21 AS build
22

3-
FROM scratch
4-
# needed for version check HTTPS request
5-
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
3+
WORKDIR /src/syft
4+
5+
# openshift-golang-builder sets GOFLAGS=-mod=vendor, unset it (we don't vendor dependencies)
6+
ENV GOFLAGS=""
7+
8+
COPY go.mod go.sum .
9+
RUN go mod download
10+
11+
COPY . .
12+
RUN ./build-syft-binary.sh
13+
14+
FROM registry.access.redhat.com/ubi9/ubi-micro:9.4-6.1716471860@sha256:1c8483e0fda0e990175eb9855a5f15e0910d2038dd397d9e2b357630f0321e6d
15+
16+
ENV SYFT_CHECK_FOR_APP_UPDATE=false
617

718
# create the /tmp dir, which is needed for image content cache
819
WORKDIR /tmp
920

10-
COPY syft /
11-
12-
ARG BUILD_DATE
13-
ARG BUILD_VERSION
14-
ARG VCS_REF
15-
ARG VCS_URL
21+
COPY --from=build /src/syft/dist/syft /usr/local/bin/syft
1622

17-
LABEL org.opencontainers.image.created=$BUILD_DATE
1823
LABEL org.opencontainers.image.title="syft"
1924
LABEL org.opencontainers.image.description="CLI tool and library for generating a Software Bill of Materials from container images and filesystems"
20-
LABEL org.opencontainers.image.source=$VCS_URL
21-
LABEL org.opencontainers.image.revision=$VCS_REF
22-
LABEL org.opencontainers.image.vendor="Anchore, Inc."
23-
LABEL org.opencontainers.image.version=$BUILD_VERSION
25+
LABEL org.opencontainers.image.vendor="Red Hat, Inc."
2426
LABEL org.opencontainers.image.licenses="Apache-2.0"
25-
LABEL io.artifacthub.package.readme-url="https://raw.githubusercontent.com/anchore/syft/main/README.md"
26-
LABEL io.artifacthub.package.logo-url="https://user-images.githubusercontent.com/5199289/136844524-1527b09f-c5cb-4aa9-be54-5aa92a6086c1.png"
27-
LABEL io.artifacthub.package.license="Apache-2.0"
2827

29-
ENTRYPOINT ["/syft"]
28+
# required per https://github.com/release-engineering/rhtap-ec-policy/blob/main/data/rule_data.yml
29+
# TODO: set up in Bugzilla
30+
LABEL com.redhat.component="syft"
31+
LABEL version="1.8.0"
32+
# TODO: document the need to bump this on every re-release of the same version
33+
LABEL release="1"
34+
LABEL name="syft"
35+
LABEL io.k8s.display-name="syft"
36+
LABEL summary="syft"
37+
LABEL description="CLI tool and library for generating a Software Bill of Materials from container images and filesystems"
38+
LABEL io.k8s.description="CLI tool and library for generating a Software Bill of Materials from container images and filesystems"
39+
LABEL vendor="Red Hat, Inc."
40+
LABEL url="https://github.com/redhat-appstudio/rh-syft"
41+
LABEL distribution-scope="public"
42+
43+
ENTRYPOINT ["/usr/local/bin/syft"]

build-syft-binary.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env bash
2+
set -o errexit -o nounset -o pipefail
3+
4+
# Roughly replicate goreleaser templating: https://goreleaser.com/customization/templates/.
5+
# Needed for passing version information to the Syft build (see the upstream .goreleaser.yaml).
6+
7+
get_version() {
8+
local version
9+
version=$(git describe --tags --abbrev=0)
10+
# TODO: should we indicate the Red Hat patches in the version?
11+
# TODO: how to version re-releases of past versions?
12+
echo "${version#v}" # strip the 'v' prefix
13+
}
14+
15+
version=$(get_version)
16+
full_commit=$(git rev-parse HEAD)
17+
date="$(date --utc --iso-8601=seconds | cut -d '+' -f 1)Z" # yyyy-mm-ddThh:mm:ssZ
18+
summary=$(git describe --dirty --always --tags)
19+
20+
# command based on .goreleaser.yaml configuration
21+
CGO_ENABLED=0 go build -ldflags "
22+
-w
23+
-s
24+
-extldflags '-static'
25+
-X main.version=$version
26+
-X main.gitCommit=$full_commit
27+
-X main.buildDate=$date
28+
-X main.gitDescription=$summary
29+
" -o dist/syft ./cmd/syft
30+
31+
echo "--- output path: dist/syft ---"
32+
dist/syft version

0 commit comments

Comments
 (0)