forked from Contrast-Security-OSS/go-test-bench
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.agent
39 lines (29 loc) · 1 KB
/
Dockerfile.agent
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
35
36
37
38
39
FROM golang:latest AS builder
WORKDIR /build
COPY . .
# Install the necessary ubuntu dependencies
RUN apt-get update
RUN apt-get install -y gnupg2 ca-certificates curl software-properties-common
# Add the contrast public key
ADD https://pkg.contrastsecurity.com/api/gpg/key/public ./publickey
RUN apt-key add ./publickey
RUN add-apt-repository "deb https://pkg.contrastsecurity.com/debian-public/ focal contrast"
# Install contrast-go
RUN apt-get update
RUN apt-get install -y contrast-go
# Fetch dependencies.
RUN go get -d -v
# Build the binary
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 contrast-go build \
-ldflags='-w -s -extldflags "-static"' -a \
-o app .
# Move the finished build to a scratch container
FROM scratch
# Copy the testbench to the new scratch container
COPY --from=builder /build/views ./views
COPY --from=builder /build/public ./public
COPY --from=builder /build/app ./app
# Copy the contrast_security.yaml
COPY ./contrast_security.yaml .
# Execute the testbench agent
ENTRYPOINT ["./app"]