Dockerfile 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. #
  10. # This Dockerfile includes all the tailscale binaries.
  11. #
  12. # To build the Dockerfile:
  13. #
  14. # $ docker build -t tailscale/tailscale .
  15. #
  16. # To run the tailscaled agent:
  17. #
  18. # $ docker run -d --name=tailscaled -v /var/lib:/var/lib -v /dev/net/tun:/dev/net/tun --network=host --privileged tailscale/tailscale tailscaled
  19. #
  20. # To then log in:
  21. #
  22. # $ docker exec tailscaled tailscale up
  23. #
  24. # To see status:
  25. #
  26. # $ docker exec tailscaled tailscale status
  27. FROM golang:1.23-alpine AS build-env
  28. WORKDIR /go/src/tailscale
  29. COPY go.mod go.sum ./
  30. RUN go mod download
  31. # Pre-build some stuff before the following COPY line invalidates the Docker cache.
  32. RUN go install \
  33. github.com/aws/aws-sdk-go-v2/aws \
  34. github.com/aws/aws-sdk-go-v2/config \
  35. gvisor.dev/gvisor/pkg/tcpip/adapters/gonet \
  36. gvisor.dev/gvisor/pkg/tcpip/stack \
  37. golang.org/x/crypto/ssh \
  38. golang.org/x/crypto/acme \
  39. github.com/coder/websocket \
  40. github.com/mdlayher/netlink
  41. COPY . .
  42. # see build_docker.sh
  43. ARG VERSION_LONG=""
  44. ENV VERSION_LONG=$VERSION_LONG
  45. ARG VERSION_SHORT=""
  46. ENV VERSION_SHORT=$VERSION_SHORT
  47. ARG VERSION_GIT_HASH=""
  48. ENV VERSION_GIT_HASH=$VERSION_GIT_HASH
  49. ARG TARGETARCH
  50. RUN GOARCH=$TARGETARCH go install -ldflags="\
  51. -X tailscale.com/version.longStamp=$VERSION_LONG \
  52. -X tailscale.com/version.shortStamp=$VERSION_SHORT \
  53. -X tailscale.com/version.gitCommitStamp=$VERSION_GIT_HASH" \
  54. -v ./cmd/tailscale ./cmd/tailscaled ./cmd/containerboot
  55. FROM alpine:3.18
  56. RUN apk add --no-cache ca-certificates iptables iproute2 ip6tables
  57. COPY --from=build-env /go/bin/* /usr/local/bin/
  58. # For compat with the previous run.sh, although ideally you should be
  59. # using build_docker.sh which sets an entrypoint for the image.
  60. RUN mkdir /tailscale && ln -s /usr/local/bin/containerboot /tailscale/run.sh