cloudfoundry/cf-k8s-controllers

View on GitHub
api/remote-debug/Dockerfile

Summary

Maintainability
Test Coverage
# syntax = docker/dockerfile:experimental
FROM golang:1.22.4 as builder

ARG version=dev

WORKDIR /workspace

COPY go.mod go.sum ./

RUN --mount=type=cache,target=/go/pkg/mod \
    go mod download

COPY api/actions api/actions
COPY api/errors api/errors
COPY api/authorization api/authorization
COPY api/config/config.go api/config/config.go
COPY api/handlers api/handlers
COPY api/main.go api/main.go
COPY api/middleware api/middleware
COPY api/payloads api/payloads
COPY api/presenter api/presenter
COPY api/repositories api/repositories
COPY api/routing api/routing
COPY controllers/api controllers/api
COPY controllers/config controllers/config
COPY controllers/controllers/shared controllers/controllers/shared
COPY controllers/controllers/workloads controllers/controllers/workloads
COPY controllers/webhooks controllers/webhooks
COPY tools tools
COPY version version

RUN --mount=type=cache,target=/root/.cache/go-build \
    --mount=type=cache,target=/go/pkg/mod \
    CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-X code.cloudfoundry.org/korifi/version.Version=${version}" -gcflags=all="-N -l" -o cfapi api/main.go

# Get Delve from a GOPATH not from a Go Modules project
WORKDIR /go/src/
RUN go install github.com/go-delve/delve/cmd/dlv@latest

FROM ubuntu

WORKDIR /
COPY --from=builder /workspace/cfapi .
COPY --from=builder /go/bin/dlv .
USER 1000:1000

CMD ["/dlv", "--listen=:40000", "--headless=true", "--api-version=2", "exec", "/cfapi", "--continue", "--accept-multiclient"]