Dockerfile 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 Docker,
  7. # Kubernetes, etc.
  8. #
  9. # It might work, but we don't regularly test it, and it's not as polished as
  10. # our currently supported platforms. This is provided for people who know
  11. # how Tailscale works and what they're doing.
  12. #
  13. # Our tracking bug for officially support container use cases is:
  14. # https://github.com/tailscale/tailscale/issues/504
  15. #
  16. # Also, see the various bugs tagged "containers":
  17. # https://github.com/tailscale/tailscale/labels/containers
  18. #
  19. ############################################################################
  20. # This Dockerfile includes all the tailscale binaries.
  21. #
  22. # To build the Dockerfile:
  23. #
  24. # $ docker build -t tailscale:tailscale .
  25. #
  26. # To run the tailscaled agent:
  27. #
  28. # $ docker run -d --name=tailscaled -v /var/lib:/var/lib -v /dev/net/tun:/dev/net/tun --network=host --privileged tailscale:tailscale tailscaled
  29. #
  30. # To then log in:
  31. #
  32. # $ docker exec tailscaled tailscale up
  33. #
  34. # To see status:
  35. #
  36. # $ docker exec tailscaled tailscale status
  37. FROM golang:1.16-alpine AS build-env
  38. WORKDIR /go/src/tailscale
  39. COPY go.mod .
  40. COPY go.sum .
  41. RUN go mod download
  42. COPY . .
  43. # see build_docker.sh
  44. ARG VERSION_LONG=""
  45. ENV VERSION_LONG=$VERSION_LONG
  46. ARG VERSION_SHORT=""
  47. ENV VERSION_SHORT=$VERSION_SHORT
  48. ARG VERSION_GIT_HASH=""
  49. ENV VERSION_GIT_HASH=$VERSION_GIT_HASH
  50. RUN go install -tags=xversion -ldflags="\
  51. -X tailscale.com/version.Long=$VERSION_LONG \
  52. -X tailscale.com/version.Short=$VERSION_SHORT \
  53. -X tailscale.com/version.GitCommit=$VERSION_GIT_HASH" \
  54. -v ./cmd/...
  55. FROM alpine:3.11
  56. RUN apk add --no-cache ca-certificates iptables iproute2
  57. COPY --from=build-env /go/bin/* /usr/local/bin/