Dockerfile 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. # Copyright (c) Tailscale Inc & AUTHORS
  2. # SPDX-License-Identifier: BSD-3-Clause
  3. ############################################################################
  4. #
  5. # WARNING: Tailscale is not yet officially supported in container
  6. # environments, such as Docker and Kubernetes. Though it should work, we
  7. # don't regularly test it, and we know there are some feature limitations.
  8. #
  9. # See current bugs tagged "containers":
  10. # https://github.com/tailscale/tailscale/labels/containers
  11. #
  12. ############################################################################
  13. # This Dockerfile includes all the tailscale binaries.
  14. #
  15. # To build the Dockerfile:
  16. #
  17. # $ docker build -t tailscale/tailscale .
  18. #
  19. # To run the tailscaled agent:
  20. #
  21. # $ docker run -d --name=tailscaled -v /var/lib:/var/lib -v /dev/net/tun:/dev/net/tun --network=host --privileged tailscale/tailscale tailscaled
  22. #
  23. # To then log in:
  24. #
  25. # $ docker exec tailscaled tailscale up
  26. #
  27. # To see status:
  28. #
  29. # $ docker exec tailscaled tailscale status
  30. FROM golang:1.21-alpine AS build-env
  31. WORKDIR /go/src/tailscale
  32. COPY go.mod go.sum ./
  33. RUN go mod download
  34. # Pre-build some stuff before the following COPY line invalidates the Docker cache.
  35. RUN go install \
  36. github.com/aws/aws-sdk-go-v2/aws \
  37. github.com/aws/aws-sdk-go-v2/config \
  38. gvisor.dev/gvisor/pkg/tcpip/adapters/gonet \
  39. gvisor.dev/gvisor/pkg/tcpip/stack \
  40. golang.org/x/crypto/ssh \
  41. golang.org/x/crypto/acme \
  42. nhooyr.io/websocket \
  43. github.com/mdlayher/netlink
  44. COPY . .
  45. # see build_docker.sh
  46. ARG VERSION_LONG=""
  47. ENV VERSION_LONG=$VERSION_LONG
  48. ARG VERSION_SHORT=""
  49. ENV VERSION_SHORT=$VERSION_SHORT
  50. ARG VERSION_GIT_HASH=""
  51. ENV VERSION_GIT_HASH=$VERSION_GIT_HASH
  52. ARG TARGETARCH
  53. RUN GOARCH=$TARGETARCH go install -ldflags="\
  54. -X tailscale.com/version.longStamp=$VERSION_LONG \
  55. -X tailscale.com/version.shortStamp=$VERSION_SHORT \
  56. -X tailscale.com/version.gitCommitStamp=$VERSION_GIT_HASH" \
  57. -v ./cmd/tailscale ./cmd/tailscaled ./cmd/containerboot
  58. FROM alpine:3.16
  59. RUN apk add --no-cache ca-certificates iptables iproute2 ip6tables
  60. COPY --from=build-env /go/bin/* /usr/local/bin/
  61. # For compat with the previous run.sh, although ideally you should be
  62. # using build_docker.sh which sets an entrypoint for the image.
  63. RUN mkdir /tailscale && ln -s /usr/local/bin/containerboot /tailscale/run.sh