Dockerfile 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. # Copyright (c) Tailscale Inc & AUTHORS
  2. # SPDX-License-Identifier: BSD-3-Clause
  3. # Note that this Dockerfile is currently NOT used to build any of the published
  4. # Tailscale container images and may have drifted from the image build mechanism
  5. # we use.
  6. # Tailscale images are currently built using https://github.com/tailscale/mkctr,
  7. # and the build script can be found in ./build_docker.sh.
  8. #
  9. # If you want to build local images for testing, you can use make.
  10. #
  11. # To build a Tailscale image and push to the local docker registry:
  12. #
  13. # $ REPO=local/tailscale TAGS=v0.0.1 PLATFORM=local make publishdevimage
  14. #
  15. # To build a Tailscale image and push to a remote docker registry:
  16. #
  17. # $ REPO=<your-registry>/<your-repo>/tailscale TAGS=v0.0.1 make publishdevimage
  18. #
  19. # This Dockerfile includes all the tailscale binaries.
  20. #
  21. # To build the Dockerfile:
  22. #
  23. # $ docker build -t tailscale/tailscale .
  24. #
  25. # To run the tailscaled agent:
  26. #
  27. # $ docker run -d --name=tailscaled -v /var/lib:/var/lib -v /dev/net/tun:/dev/net/tun --network=host --privileged tailscale/tailscale tailscaled
  28. #
  29. # To then log in:
  30. #
  31. # $ docker exec tailscaled tailscale up
  32. #
  33. # To see status:
  34. #
  35. # $ docker exec tailscaled tailscale status
  36. FROM golang:1.25-alpine AS build-env
  37. WORKDIR /go/src/tailscale
  38. COPY go.mod go.sum ./
  39. RUN go mod download
  40. # Pre-build some stuff before the following COPY line invalidates the Docker cache.
  41. RUN go install \
  42. github.com/aws/aws-sdk-go-v2/aws \
  43. github.com/aws/aws-sdk-go-v2/config \
  44. gvisor.dev/gvisor/pkg/tcpip/adapters/gonet \
  45. gvisor.dev/gvisor/pkg/tcpip/stack \
  46. golang.org/x/crypto/ssh \
  47. golang.org/x/crypto/acme \
  48. github.com/coder/websocket \
  49. github.com/mdlayher/netlink
  50. COPY . .
  51. # see build_docker.sh
  52. ARG VERSION_LONG=""
  53. ENV VERSION_LONG=$VERSION_LONG
  54. ARG VERSION_SHORT=""
  55. ENV VERSION_SHORT=$VERSION_SHORT
  56. ARG VERSION_GIT_HASH=""
  57. ENV VERSION_GIT_HASH=$VERSION_GIT_HASH
  58. ARG TARGETARCH
  59. RUN GOARCH=$TARGETARCH go install -ldflags="\
  60. -X tailscale.com/version.longStamp=$VERSION_LONG \
  61. -X tailscale.com/version.shortStamp=$VERSION_SHORT \
  62. -X tailscale.com/version.gitCommitStamp=$VERSION_GIT_HASH" \
  63. -v ./cmd/tailscale ./cmd/tailscaled ./cmd/containerboot
  64. FROM alpine:3.22
  65. RUN apk add --no-cache ca-certificates iptables iproute2 ip6tables
  66. RUN ln -s /sbin/iptables-legacy /sbin/iptables
  67. RUN ln -s /sbin/ip6tables-legacy /sbin/ip6tables
  68. COPY --from=build-env /go/bin/* /usr/local/bin/
  69. # For compat with the previous run.sh, although ideally you should be
  70. # using build_docker.sh which sets an entrypoint for the image.
  71. RUN mkdir /tailscale && ln -s /usr/local/bin/containerboot /tailscale/run.sh