diff --git a/Makefile b/Makefile index 461336ef2c39f..47ef55d0bdc64 100644 --- a/Makefile +++ b/Makefile @@ -296,6 +296,11 @@ $(BUILDDIR)/tctl: $(BUILDDIR)/teleport: ensure-webassets bpf-bytecode rdpclient GOOS=$(OS) GOARCH=$(ARCH) $(CGOFLAG) go build -tags "webassets_embed $(PAM_TAG) $(FIPS_TAG) $(BPF_TAG) $(WEBASSETS_TAG) $(RDPCLIENT_TAG) $(PIV_BUILD_TAG)" -o $(BUILDDIR)/teleport $(BUILDFLAGS) ./tool/teleport +TELEPORT_ARGS ?= start +.PHONY: teleport-hot-reload +teleport-hot-reload: + CompileDaemon --graceful-kill=true --exclude-dir=".git" --exclude-dir="node_modules" --build="make $(BUILDDIR)/teleport" --command="$(BUILDDIR)/teleport $(TELEPORT_ARGS)" + # NOTE: Any changes to the `tsh` build here must be copied to `windows.go` in Dronegen until # we can use this Makefile for native Windows builds. .PHONY: $(BUILDDIR)/tsh diff --git a/README.md b/README.md index 184d2404b7d98..42081849a55fe 100644 --- a/README.md +++ b/README.md @@ -213,6 +213,41 @@ sudo mkdir -p -m0700 /var/lib/teleport sudo chown $USER /var/lib/teleport ``` +#### Running Teleport in a hot reload mode + +To speed up your development process, you can run Teleport using +[`CompileDaemon`](https://github.com/githubnemo/CompileDaemon). This will build +and run the Teleport binary, and then rebuild and restart it whenever any Go +source files change. + +1. Install CompileDaemon: + + ```shell + go install github.com/githubnemo/CompileDaemon@latest + ``` + + Note that we use `go install` instead of the suggested `go get`, because we + don't want CompileDaemon to become a dependency of the project. + +1. Build and run the Teleport binary: + + ```shell + make teleport-hot-reload + ``` + + By default, this runs a `teleport start` command. If you want to customize + the command, for example by providing a custom config file location, you can + use the `TELEPORT_ARGS` parameter: + + ```shell + make teleport-hot-reload TELEPORT_ARGS='start --config=/path/to/config.yaml' + ``` + +Note that you still need to run [`make grpc`](api/proto/README.md) if you modify +any Protocol Buffers files to regenerate the generated Go sources; regenerating +these sources should in turn cause the CompileDaemon to rebuild and restart +Teleport. + ### Web UI The Teleport Web UI resides in the [web](web) directory.