docs/development/developing-dapr.md
There are several options for getting an environment up and running for Dapr development:
Contributing to Dapr often requires working with multiple repositories at once. We recommend creating a folder for Dapr and cloning all forked repositories in that folder.
For instructions on how to fork a repo, see this video on forking the dapr/docs repo. The process is the same, just for different repositories.
mkdir dapr
git clone https://github.com/dapr/dapr.git dapr/dapr
You can build Dapr binaries with the make tool.
On Windows, the
makecommands must be run under git-bash.These instructions also require that a
makealias has been created formingw32-make.exeaccording to the setup instructions.
When running make, you need to be at the root of the dapr/dapr repo directory, for example: $GOPATH/src/github.com/dapr/dapr.
Once built, the release binaries will be found in ./dist/{os}_{arch}/release/, where {os}_{arch} is your current OS and architecture.
For example, running make build on an Intel-based macOS will generate the directory ./dist/darwin_amd64/release.
To build for your current local environment:
cd dapr/dapr
make build
To cross-compile for a different platform, use the GOOS and GOARCH environmental variables:
make build GOOS=windows GOARCH=amd64
For example, developers on Windows who prefer to develop in WSL2 can use the Linux development environment to cross-compile binaries like
daprd.exethat run on Windows natively.
You can individually build the daprd binary:
cd cmd/daprd
go build -tags=allcomponents -v
# use it in this manner
./daprd ...
# if you need to execute a `dapr run` command with that newly-built binary:
mv daprd ~/.dapr/bin/daprd
dapr version # see `Runtime version: edge` to ensure you are using the newly built binary
dapr run ... # this will use the newly-built binary
make test
make check
This command will:
git commit somethingNote: To run linter locally, please use golangci-lint version v2.4.0, otherwise you might encounter errors. You can download version v2.4.0 here.
We recommend using VS Code with the Go extension for your productivity. If you want to use other code editors, please refer to the list of editor plugins for Delve.
This section introduces how to start debugging with the Delve CLI. Please refer to the Delve documentation for more details.
To start the Dapr runtime with a debugger, you need to use build tags to include the components you want to debug. The following build tags are available:
$ cd dapr/dapr/cmd/daprd
$ dlv debug . --build-flags=--tags=allcomponents
Type 'help' for list of commands.
(dlv) break main.main
(dlv) continue
This is useful to debug Dapr when the process is running.
Build Dapr binaries for debugging.
Use the DEBUG=1 option to generate Dapr binaries without code optimization in ./dist/{os}_{arch}/debug/
make DEBUG=1 build
Create a component YAML file under ./dist/{os}_{arch}/debug/components (for example a statestore component YAML).
Start the Dapr runtime
/dist/{os}_{arch}/debug/daprd
Find the process ID (e.g. PID displayed by the ps command for daprd) and attach the debugger
dlv attach {PID}
go build -tags=allcomponents -v from /cmd/daprd.Specify the package that you want to test when running the dlv test. For example, to debug the ./pkg/actors tests:
dlv test ./pkg/actors
docker.io/<your_docker_hub_account>.dev is a common choice).true to use a single dapr image instead of individual images (like sentry, injector, daprd, etc.).On Linux/macOS:
export DAPR_REGISTRY=docker.io/<your_docker_hub_account>
export DAPR_TAG=dev
On Windows:
set DAPR_REGISTRY=docker.io/<your_docker_hub_account>
set DAPR_TAG=dev
# Build Linux binaries
make build-linux
# Build Docker image with Linux binaries
make docker-build
To push the image to DockerHub, complete your docker login and run:
make docker-push
Now we'll deploy Dapr with your changes.
To create the dapr-system namespace:
kubectl create namespace dapr-system
If you deployed Dapr to your cluster before, delete it now using:
helm uninstall dapr -n dapr-system
To deploy your changes to your Kubernetes cluster:
make docker-deploy-k8s
Once Dapr is deployed, list the Dapr pods:
$ kubectl get pod -n dapr-system
NAME READY STATUS RESTARTS AGE
dapr-operator-86cddcfcb7-v2zjp 1/1 Running 0 4d3h
dapr-placement-5d6465f8d5-pz2qt 1/1 Running 0 4d3h
dapr-sidecar-injector-dc489d7bc-k2h4q 1/1 Running 0 4d3h
Refer to the Dapr Docs on how to: