Repository navigation
Expand file tree
/
Copy pathDockerfile.integration
More file actions
47 lines (35 loc) · 1.74 KB
/
Copy pathDockerfile.integration
File metadata and controls
47 lines (35 loc) · 1.74 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
# This Dockerfile and the images produced are for testing slopscale,
# and are in no way endorsed by Slopscale's maintainers as an
# official nor supported release or distribution.
FROM docker.io/golang:1.27.2-trixie AS builder
ARG VERSION=dev
ENV GOPATH /go
WORKDIR /go/src/slopscale
# Install delve debugger first - rarely changes, good cache candidate
RUN go install github.com/go-delve/delve/cmd/dlv@latest
# Download dependencies - only invalidated when go.mod/go.sum change
COPY go.mod go.sum /go/src/slopscale/
RUN go mod download
# Copy source and build - invalidated on any source change
COPY . .
# Build debug binary with debug symbols for delve. The SQLite driver is C
# compiled by cgo with the flags from sqlite.cflags; the builder and the
# runtime image share the same Debian release, so dynamic linking is fine.
RUN CGO_ENABLED=1 CGO_CFLAGS="$(grep -v '^#' sqlite.cflags | tr '\n' ' ')" GOOS=linux \
go build -gcflags="all=-N -l" -o /go/bin/slopscale ./cmd/slopscale
# Runtime stage
FROM debian:trixie-slim
RUN apt-get --update install --no-install-recommends --yes \
bash ca-certificates curl dnsutils findutils iproute2 jq less procps python3 sqlite3 \
&& apt-get dist-clean
RUN mkdir -p /var/run/slopscale
# Copy binaries from builder
COPY --from=builder /go/bin/slopscale /usr/local/bin/slopscale
COPY --from=builder /go/bin/dlv /usr/local/bin/dlv
# Copy source code for delve source-level debugging
COPY --from=builder /go/src/slopscale /go/src/slopscale
WORKDIR /go/src/slopscale
# Need to reset the entrypoint or everything will run as a busybox script
ENTRYPOINT []
EXPOSE 8080/tcp 40000/tcp
CMD ["dlv", "--listen=0.0.0.0:40000", "--headless=true", "--api-version=2", "--accept-multiclient", "exec", "/usr/local/bin/slopscale", "--"]