Skip to content

Commit 43a311c

Browse files
committed
SBOM
1 parent 8820b99 commit 43a311c

File tree

2 files changed

+34
-16
lines changed

2 files changed

+34
-16
lines changed

Dockerfile

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,58 @@
1-
FROM golang:latest AS stage
1+
FROM golang:latest AS builder
22

33
WORKDIR /build
44

5+
# Install Syft for SBOM generation
6+
RUN go install github.com/anchore/syft/cmd/syft@latest
7+
8+
# Copy source code
59
COPY . .
10+
11+
# Tidy dependencies
612
RUN go mod tidy
13+
14+
# Build the Go binary
715
RUN CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -ldflags "-linkmode external -extldflags -static" -a -installsuffix cgo -o main_linux_amd64.bin main.go
16+
17+
# Generate SBOM for the application
18+
# This scans the built binary and vendor dependencies
19+
RUN /go/bin/syft packages . -o spdx-json=sbom.spdx.json
20+
21+
# Generate a checksum for the binary
822
RUN sha256sum main_linux_amd64.bin > main_linux_amd64.bin.sha256sum
923

24+
1025
FROM alpine:latest
1126

1227
WORKDIR /app
13-
VOLUME /app/videos
14-
VOLUME /app/public
15-
VOLUME /app/database
1628

17-
RUN apk add ffmpeg bash
18-
COPY --from=stage ./build/main_linux_amd64.bin ./
19-
RUN mv ./main_linux_amd64.bin ./main.bin
29+
# System dependencies
30+
RUN apk add --no-cache ffmpeg bash
31+
32+
# Copy the application binary from the builder stage
33+
COPY --from=builder /build/main_linux_amd64.bin ./main.bin
34+
35+
# Copy the SBOM from the builder stage
36+
COPY --from=builder /build/sbom.spdx.json /app/sbom.spdx.json
37+
38+
# Copy other necessary application files
2039
COPY ./views ./views/
2140
COPY ./public ./public/
2241

42+
# Set up volumes for persistent data
43+
VOLUME /app/videos
44+
VOLUME /app/public
45+
VOLUME /app/database
46+
47+
# Environment variables
2348
ENV Host=:3000
2449
ENV FolderVideoQualitysPriv=./videos/qualitys
2550
ENV FolderVideoQualitysPub=/videos/qualitys
2651
ENV FolderVideoUploadsPriv=./videos/uploads
2752
ENV StatsDriveName=nvme0n1
2853

54+
# Expose the application port
2955
EXPOSE 3000
3056

57+
# Define the command to run the application
3158
CMD ["./main.bin", "serve:main"]

cloud-config.yaml

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)