Skip to content

Commit

Permalink
Pre-build the tsnet dep on the go module layer
Browse files Browse the repository at this point in the history
This should concentrate the bulk of the build duration on the
dependency level, since it's tsnet that pulls in all those
libraries (and it changes rarely).
  • Loading branch information
antifuchs committed Aug 16, 2023
1 parent 6877b05 commit 3e59d40
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ WORKDIR /work
ENV CGO_ENABLED=0

COPY go.mod go.sum ./
RUN go mod download && go mod verify
RUN go mod download && \
go mod verify && \
echo 'package main\nimport (_ "tailscale.com/tsnet")\nfunc main(){}' > main.go && \
go build -v ./ && \
rm main.go

COPY . .

Expand All @@ -13,4 +17,4 @@ RUN go build -ldflags="-s -w" -v
FROM scratch
COPY --from=builder /work/tsnsrv /usr/bin/tsnsrv

CMD ["/usr/bin/tsnsrv"]
CMD ["/usr/bin/tsnsrv"]

0 comments on commit 3e59d40

Please sign in to comment.