Dockerfile 2.4 KB

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