Dockerfile 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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.17-alpine AS build-env
  32. WORKDIR /go/src/tailscale
  33. COPY go.mod go.sum ./
  34. RUN go mod download
  35. COPY . .
  36. # see build_docker.sh
  37. ARG VERSION_LONG=""
  38. ENV VERSION_LONG=$VERSION_LONG
  39. ARG VERSION_SHORT=""
  40. ENV VERSION_SHORT=$VERSION_SHORT
  41. ARG VERSION_GIT_HASH=""
  42. ENV VERSION_GIT_HASH=$VERSION_GIT_HASH
  43. ARG TARGETARCH
  44. RUN GOARCH=$TARGETARCH go install -tags=xversion -ldflags="\
  45. -X tailscale.com/version.Long=$VERSION_LONG \
  46. -X tailscale.com/version.Short=$VERSION_SHORT \
  47. -X tailscale.com/version.GitCommit=$VERSION_GIT_HASH" \
  48. -v ./cmd/tailscale ./cmd/tailscaled
  49. FROM alpine:3.14
  50. RUN apk add --no-cache ca-certificates iptables iproute2 ip6tables
  51. COPY --from=build-env /go/bin/* /usr/local/bin/