-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDockerfile.debug
More file actions
60 lines (46 loc) · 1.69 KB
/
Dockerfile.debug
File metadata and controls
60 lines (46 loc) · 1.69 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
54
55
56
57
58
59
60
# Build the manager binary with debug symbols
ARG GO_VERSION=1.25.0
FROM docker.io/golang:${GO_VERSION} AS builder
ARG TARGETOS
ARG TARGETARCH
WORKDIR /workspace
# Install Delve for debugging
RUN go install github.com/go-delve/delve/cmd/dlv@latest
# Copy the Go Modules manifests
COPY go.mod go.mod
COPY go.sum go.sum
# cache deps before building and copying source so that we don't need to re-download as much
# and so that source changes don't invalidate our downloaded layer
RUN go mod download
# Copy the go source
COPY cmd/main.go cmd/main.go
COPY api/ api/
COPY internal/ internal/
COPY pkg/ pkg/
# Build with debug symbols (no optimization, with debug info)
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build \
-gcflags="all=-N -l" \
-o manager cmd/main.go
# Generate self-signed cert
RUN mkdir -p /certs && \
openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
-keyout /certs/tls.key -out /certs/tls.crt \
-subj "/CN=local.svc"
# Use a more complete base image for debugging
FROM gcr.io/distroless/base-debian12:debug
WORKDIR /
# Copy delve debugger
COPY --from=builder /go/bin/dlv /dlv
# Copy manager binary
COPY --from=builder /workspace/manager .
# Copy config files
COPY config/configs/instance.yaml instance.yaml
COPY config/configs/applications.yaml applications.yaml
COPY config/configs/features/ features/
COPY --from=builder /certs/tls.crt /certs/tls.crt
COPY --from=builder /certs/tls.key /certs/tls.key
USER 65532:65532
ENV INSTANCE_FILE=/instance.yaml
ENV APPLICATION_FILE=/applications.yaml
# Start with delve for debugging
ENTRYPOINT ["/dlv", "--listen=:2345", "--headless=true", "--api-version=2", "--accept-multiclient", "exec", "/manager", "--"]