mirror of
https://github.com/juanfont/headscale.git
synced 2026-02-15 12:17:40 +01:00
This commit upgrades the codebase from Go 1.25.5 to Go 1.26rc2 and adopts new language features. Toolchain updates: - go.mod: go 1.25.5 → go 1.26rc2 - flake.nix: buildGo125Module → buildGo126Module, go_1_25 → go_1_26 - flake.nix: build golangci-lint from source with Go 1.26 - Dockerfile.integration: golang:1.25-trixie → golang:1.26rc2-trixie - Dockerfile.tailscale-HEAD: golang:1.25-alpine → golang:1.26rc2-alpine - Dockerfile.derper: golang:alpine → golang:1.26rc2-alpine - .goreleaser.yml: go mod tidy -compat=1.25 → -compat=1.26 - cmd/hi/run.go: fallback Go version 1.25 → 1.26rc2 - .pre-commit-config.yaml: simplify golangci-lint hook entry Code modernization using Go 1.26 features: - Replace tsaddr.SortPrefixes with slices.SortFunc + netip.Prefix.Compare - Replace ptr.To(x) with new(x) syntax - Replace errors.As with errors.AsType[T] Lint rule updates: - Add forbidigo rules to prevent regression to old patterns
45 lines
1.5 KiB
Docker
45 lines
1.5 KiB
Docker
# This Dockerfile and the images produced are for testing headscale,
|
|
# and are in no way endorsed by Headscale's maintainers as an
|
|
# official nor supported release or distribution.
|
|
|
|
FROM docker.io/golang:1.26rc2-trixie AS builder
|
|
ARG VERSION=dev
|
|
ENV GOPATH /go
|
|
WORKDIR /go/src/headscale
|
|
|
|
# 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/headscale/
|
|
RUN go mod download
|
|
|
|
# Copy source and build - invalidated on any source change
|
|
COPY . .
|
|
|
|
# Build debug binary with debug symbols for delve
|
|
RUN CGO_ENABLED=0 GOOS=linux go build -gcflags="all=-N -l" -o /go/bin/headscale ./cmd/headscale
|
|
|
|
# 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/headscale
|
|
|
|
# Copy binaries from builder
|
|
COPY --from=builder /go/bin/headscale /usr/local/bin/headscale
|
|
COPY --from=builder /go/bin/dlv /usr/local/bin/dlv
|
|
|
|
# Copy source code for delve source-level debugging
|
|
COPY --from=builder /go/src/headscale /go/src/headscale
|
|
|
|
WORKDIR /go/src/headscale
|
|
|
|
# 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/headscale", "--"]
|