-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
53 lines (39 loc) · 1.03 KB
/
Dockerfile
File metadata and controls
53 lines (39 loc) · 1.03 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# =========================
# Build Stage
# =========================
FROM golang:1.24 AS builder
WORKDIR /app
# Download dependencies
COPY go.mod go.sum ./
RUN go mod download
# Copy the source code
COPY . .
ARG TARGETARCH=amd64
# Build the Go binary
RUN CGO_ENABLED=0 GOOS=linux GOARCH=$TARGETARCH go build -o backend main.go
# =========================
# Final Stage with Trivy
# =========================
FROM alpine:3.20
# Install required packages
RUN apk --no-cache add \
ca-certificates \
curl \
bash \
tar \
gzip \
libc6-compat
# Install Trivy (static binary)
ENV TRIVY_VERSION=0.55.2
RUN curl -sfL https://github.com/aquasecurity/trivy/releases/download/v${TRIVY_VERSION}/trivy_${TRIVY_VERSION}_Linux-64bit.tar.gz \
| tar zx -C /usr/local/bin/ trivy
# Verify installation
RUN trivy --version
WORKDIR /root/
# Copy the Go binary
COPY --from=builder /app/backend .
# Allow access to Kubernetes API via a volume mount for kubeconfig
VOLUME ["/root/.kube"]
# Expose webhook port
EXPOSE 8000
CMD ["./backend"]