Makefile 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. IMAGE_REPO ?= tailscale/tailscale
  2. SYNO_ARCH ?= "x86_64"
  3. SYNO_DSM ?= "7"
  4. TAGS ?= "latest"
  5. PLATFORM ?= "flyio" ## flyio==linux/amd64. Set to "" to build all platforms.
  6. vet: ## Run go vet
  7. ./tool/go vet ./...
  8. tidy: ## Run go mod tidy
  9. ./tool/go mod tidy
  10. lint: ## Run golangci-lint
  11. ./tool/go run github.com/golangci/golangci-lint/cmd/golangci-lint run
  12. updatedeps: ## Update depaware deps
  13. # depaware (via x/tools/go/packages) shells back to "go", so make sure the "go"
  14. # it finds in its $$PATH is the right one.
  15. PATH="$$(./tool/go env GOROOT)/bin:$$PATH" ./tool/go run github.com/tailscale/depaware --update \
  16. tailscale.com/cmd/tailscaled \
  17. tailscale.com/cmd/tailscale \
  18. tailscale.com/cmd/derper \
  19. tailscale.com/cmd/k8s-operator \
  20. tailscale.com/cmd/stund
  21. depaware: ## Run depaware checks
  22. # depaware (via x/tools/go/packages) shells back to "go", so make sure the "go"
  23. # it finds in its $$PATH is the right one.
  24. PATH="$$(./tool/go env GOROOT)/bin:$$PATH" ./tool/go run github.com/tailscale/depaware --check \
  25. tailscale.com/cmd/tailscaled \
  26. tailscale.com/cmd/tailscale \
  27. tailscale.com/cmd/derper \
  28. tailscale.com/cmd/k8s-operator \
  29. tailscale.com/cmd/stund
  30. buildwindows: ## Build tailscale CLI for windows/amd64
  31. GOOS=windows GOARCH=amd64 ./tool/go install tailscale.com/cmd/tailscale tailscale.com/cmd/tailscaled
  32. build386: ## Build tailscale CLI for linux/386
  33. GOOS=linux GOARCH=386 ./tool/go install tailscale.com/cmd/tailscale tailscale.com/cmd/tailscaled
  34. buildlinuxarm: ## Build tailscale CLI for linux/arm
  35. GOOS=linux GOARCH=arm ./tool/go install tailscale.com/cmd/tailscale tailscale.com/cmd/tailscaled
  36. buildwasm: ## Build tailscale CLI for js/wasm
  37. GOOS=js GOARCH=wasm ./tool/go install ./cmd/tsconnect/wasm ./cmd/tailscale/cli
  38. buildplan9:
  39. GOOS=plan9 GOARCH=amd64 ./tool/go install ./cmd/tailscale ./cmd/tailscaled
  40. buildlinuxloong64: ## Build tailscale CLI for linux/loong64
  41. GOOS=linux GOARCH=loong64 ./tool/go install tailscale.com/cmd/tailscale tailscale.com/cmd/tailscaled
  42. buildmultiarchimage: ## Build (and optionally push) multiarch docker image
  43. ./build_docker.sh
  44. check: staticcheck vet depaware buildwindows build386 buildlinuxarm buildwasm ## Perform basic checks and compilation tests
  45. staticcheck: ## Run staticcheck.io checks
  46. ./tool/go run honnef.co/go/tools/cmd/staticcheck -- $$(./tool/go list ./... | grep -v tempfork)
  47. kube-generate-all: kube-generate-deepcopy ## Refresh generated files for Tailscale Kubernetes Operator
  48. ./tool/go generate ./cmd/k8s-operator
  49. # Tailscale operator watches Connector custom resources in a Kubernetes cluster
  50. # and caches them locally. Caching is done implicitly by controller-runtime
  51. # library (the middleware used by Tailscale operator to create kube control
  52. # loops). When a Connector resource is GET/LIST-ed from within our control loop,
  53. # the request goes through the cache. To ensure that cache contents don't get
  54. # modified by control loops, controller-runtime deep copies the requested
  55. # object. In order for this to work, Connector must implement deep copy
  56. # functionality so we autogenerate it here.
  57. # https://github.com/kubernetes-sigs/controller-runtime/blob/v0.16.3/pkg/cache/internal/cache_reader.go#L86-L89
  58. kube-generate-deepcopy: ## Refresh generated deepcopy functionality for Tailscale kube API types
  59. ./scripts/kube-deepcopy.sh
  60. spk: ## Build synology package for ${SYNO_ARCH} architecture and ${SYNO_DSM} DSM version
  61. ./tool/go run ./cmd/dist build synology/dsm${SYNO_DSM}/${SYNO_ARCH}
  62. spkall: ## Build synology packages for all architectures and DSM versions
  63. ./tool/go run ./cmd/dist build synology
  64. pushspk: spk ## Push and install synology package on ${SYNO_HOST} host
  65. echo "Pushing SPK to root@${SYNO_HOST} (env var SYNO_HOST) ..."
  66. scp tailscale.spk root@${SYNO_HOST}:
  67. ssh root@${SYNO_HOST} /usr/syno/bin/synopkg install tailscale.spk
  68. publishdevimage: ## Build and publish tailscale image to location specified by ${REPO}
  69. @test -n "${REPO}" || (echo "REPO=... required; e.g. REPO=ghcr.io/${USER}/tailscale" && exit 1)
  70. @test "${REPO}" != "tailscale/tailscale" || (echo "REPO=... must not be tailscale/tailscale" && exit 1)
  71. @test "${REPO}" != "ghcr.io/tailscale/tailscale" || (echo "REPO=... must not be ghcr.io/tailscale/tailscale" && exit 1)
  72. @test "${REPO}" != "tailscale/k8s-operator" || (echo "REPO=... must not be tailscale/k8s-operator" && exit 1)
  73. @test "${REPO}" != "ghcr.io/tailscale/k8s-operator" || (echo "REPO=... must not be ghcr.io/tailscale/k8s-operator" && exit 1)
  74. TAGS="${TAGS}" REPOS=${REPO} PLATFORM=${PLATFORM} PUSH=true TARGET=client ./build_docker.sh
  75. publishdevoperator: ## Build and publish k8s-operator image to location specified by ${REPO}
  76. @test -n "${REPO}" || (echo "REPO=... required; e.g. REPO=ghcr.io/${USER}/tailscale" && exit 1)
  77. @test "${REPO}" != "tailscale/tailscale" || (echo "REPO=... must not be tailscale/tailscale" && exit 1)
  78. @test "${REPO}" != "ghcr.io/tailscale/tailscale" || (echo "REPO=... must not be ghcr.io/tailscale/tailscale" && exit 1)
  79. @test "${REPO}" != "tailscale/k8s-operator" || (echo "REPO=... must not be tailscale/k8s-operator" && exit 1)
  80. @test "${REPO}" != "ghcr.io/tailscale/k8s-operator" || (echo "REPO=... must not be ghcr.io/tailscale/k8s-operator" && exit 1)
  81. TAGS="${TAGS}" REPOS=${REPO} PLATFORM=${PLATFORM} PUSH=true TARGET=operator ./build_docker.sh
  82. publishdevnameserver: ## Build and publish k8s-nameserver image to location specified by ${REPO}
  83. @test -n "${REPO}" || (echo "REPO=... required; e.g. REPO=ghcr.io/${USER}/tailscale" && exit 1)
  84. @test "${REPO}" != "tailscale/tailscale" || (echo "REPO=... must not be tailscale/tailscale" && exit 1)
  85. @test "${REPO}" != "ghcr.io/tailscale/tailscale" || (echo "REPO=... must not be ghcr.io/tailscale/tailscale" && exit 1)
  86. @test "${REPO}" != "tailscale/k8s-nameserver" || (echo "REPO=... must not be tailscale/k8s-nameserver" && exit 1)
  87. @test "${REPO}" != "ghcr.io/tailscale/k8s-nameserver" || (echo "REPO=... must not be ghcr.io/tailscale/k8s-nameserver" && exit 1)
  88. TAGS="${TAGS}" REPOS=${REPO} PLATFORM=${PLATFORM} PUSH=true TARGET=k8s-nameserver ./build_docker.sh
  89. .PHONY: sshintegrationtest
  90. sshintegrationtest: ## Run the SSH integration tests in various Docker containers
  91. @GOOS=linux GOARCH=amd64 ./tool/go test -tags integrationtest -c ./ssh/tailssh -o ssh/tailssh/testcontainers/tailssh.test && \
  92. GOOS=linux GOARCH=amd64 ./tool/go build -o ssh/tailssh/testcontainers/tailscaled ./cmd/tailscaled && \
  93. echo "Testing on ubuntu:focal" && docker build --build-arg="BASE=ubuntu:focal" -t ssh-ubuntu-focal ssh/tailssh/testcontainers && \
  94. echo "Testing on ubuntu:jammy" && docker build --build-arg="BASE=ubuntu:jammy" -t ssh-ubuntu-jammy ssh/tailssh/testcontainers && \
  95. echo "Testing on ubuntu:mantic" && docker build --build-arg="BASE=ubuntu:mantic" -t ssh-ubuntu-mantic ssh/tailssh/testcontainers && \
  96. echo "Testing on ubuntu:noble" && docker build --build-arg="BASE=ubuntu:noble" -t ssh-ubuntu-noble ssh/tailssh/testcontainers
  97. help: ## Show this help
  98. @echo "\nSpecify a command. The choices are:\n"
  99. @grep -hE '^[0-9a-zA-Z_-]+:.*?## .*$$' ${MAKEFILE_LIST} | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[0;36m%-20s\033[m %s\n", $$1, $$2}'
  100. @echo ""
  101. .PHONY: help
  102. .DEFAULT_GOAL := help