|
| 1 | +# Produces an image that runs cloud-init under a debugger. To use, build and push |
| 2 | +# to a registry with: |
| 3 | +# |
| 4 | +# docker buildx build -f Dockerfile.debug --load -t my-docker-tag:my-revision . |
| 5 | +# |
| 6 | +# and configure your deployment to use that image. Disable any liveness checks |
| 7 | +# (when the debugger is paused, service readiness/liveness endpoints will not respond, |
| 8 | +# and watchdogs will perceive the container as dead) and connect to the debugger listen: |
| 9 | +# |
| 10 | +# dlv connect container-hostname.example:2345 |
| 11 | + |
| 12 | +FROM golang:1.24-bookworm |
| 13 | + |
| 14 | +# Configure go env |
| 15 | +ENV GOPATH=/usr/local/golib |
| 16 | +RUN export GOPATH=$GOPATH |
| 17 | +RUN go env -w GO111MODULE=auto |
| 18 | +RUN export CGO_ENABLED=0 |
| 19 | + |
| 20 | +# Copy source files |
| 21 | +COPY cmd $GOPATH/src/github.com/OpenCHAMI/cloud-init/cmd |
| 22 | +COPY docs $GOPATH/src/github.com/OpenCHAMI/cloud-init/docs |
| 23 | +COPY pkg $GOPATH/src/github.com/OpenCHAMI/cloud-init/pkg |
| 24 | +COPY internal $GOPATH/src/github.com/OpenCHAMI/cloud-init/internal |
| 25 | +COPY go.mod $GOPATH/src/github.com/OpenCHAMI/cloud-init/go.mod |
| 26 | +COPY go.sum $GOPATH/src/github.com/OpenCHAMI/cloud-init/go.sum |
| 27 | + |
| 28 | +# Build the image |
| 29 | +RUN go build -C $GOPATH/src/github.com/OpenCHAMI/cloud-init/cmd/cloud-init-server -v \ |
| 30 | + -gcflags=all="-N -l" \ |
| 31 | + -o /usr/local/bin/cloud-init-server |
| 32 | + |
| 33 | +RUN ln -s /usr/local/bin/cloud-init-server /cloud-init-server |
| 34 | + |
| 35 | +RUN go install github.com/go-delve/delve/cmd/dlv@v1.24.0 |
| 36 | +RUN apt update; apt install tini |
| 37 | + |
| 38 | +USER 65534:65534 |
| 39 | + |
| 40 | +ENTRYPOINT ["tini", "--"] |
| 41 | +CMD ["/usr/local/golib/bin/dlv", "exec", "--continue", "--accept-multiclient", "--headless", "--api-version=2", "--listen=:2345", "--log", "/usr/local/bin/cloud-init-server"] |
0 commit comments