forked from openclarity/openclarity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.sbom_db
34 lines (26 loc) · 1.13 KB
/
Dockerfile.sbom_db
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# syntax=docker/dockerfile:1.2
FROM golang:1.20.5-alpine AS builder
RUN apk add --update --no-cache gcc g++ git ca-certificates build-base
# Copy sbom db api code
WORKDIR /build/sbom_db
COPY sbom_db/api ./api
# Copy sbom db code
WORKDIR /build/sbom_db/backend
COPY sbom_db/backend .
# Build sbom DB code
# NOTE(sambetts) Declare ARGs where they are used to prevent Docker rerunning
# all the previous steps when they change, and use buildkit inline cache to
# keep go mod cache and compilation cache between docker runs.
ARG VERSION
ARG BUILD_TIMESTAMP
ARG COMMIT_HASH
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
go build -ldflags="-s -w \
-X 'github.com/openclarity/kubeclarity/sbom_db/backend/pkg/version.Version=${VERSION}' \
-X 'github.com/openclarity/kubeclarity/sbom_db/backend/pkg/version.CommitHash=${COMMIT_HASH}' \
-X 'github.com/openclarity/kubeclarity/sbom_db/backend/pkg/version.BuildTimestamp=${BUILD_TIMESTAMP}'" -o sbom_db ./cmd/main.go
FROM alpine:3.18
WORKDIR /app
COPY --from=builder ["/build/sbom_db/backend/sbom_db", "./sbom_db"]
ENTRYPOINT ["/app/sbom_db"]