-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathContainerfile.agent-debug
47 lines (33 loc) · 1.3 KB
/
Containerfile.agent-debug
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
# UI stage
FROM --platform=linux/amd64 registry.access.redhat.com/ubi9/ubi as ui
WORKDIR /app
RUN mkdir /app/www && \
curl -Lo /tmp/agent-latest.tgz https://github.com/kubev2v/migration-planner-ui/releases/download/latest/agent-latest.tgz && \
tar xf /tmp/agent-latest.tgz -C /app/www
# Builder stage
FROM --platform=linux/amd64 registry.access.redhat.com/ubi9/go-toolset as builder
WORKDIR /app
RUN GOBIN=/app go install github.com/go-delve/delve/cmd/dlv@latest
COPY go.mod go.sum ./
RUN go mod download
COPY . .
ARG VERSION
ENV VERSION=${VERSION}
USER 0
# Build binary with debug flags
RUN CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -buildvcs=false \
-gcflags "all=-N -l" \
-ldflags "-X github.com/kubev2v/migration-planner/internal/agent.version=${VERSION}" \
-o /planner-agent cmd/planner-agent/main.go
# Final image
FROM --platform=linux/amd64 registry.access.redhat.com/ubi9/ubi-minimal
WORKDIR /app
# Install Delve runtime binary
COPY --from=builder /app/dlv /app/dlv
COPY --from=builder /planner-agent /app/planner-agent
COPY --from=ui /app/www/package/dist /app/www
# Use non-root user
RUN chown -R 1001:0 /app
USER 1001
EXPOSE 3333 40001
ENTRYPOINT ["/app/dlv", "exec", "/app/planner-agent", "--headless", "--listen=:40001", "--api-version=2", "--accept-multiclient", "--continue", "--"]