github.com/kaisenlinux/docker@v0.0.0-20230510090727-ea55db55fac7/swarmkit/BUILDING.md (about) 1 ## Build the development environment 2 3 To build Swarmkit, you must set up a Go development environment. 4 [How to Write Go Code](https://golang.org/doc/code.html) contains full instructions. 5 When setup correctly, you should have a GOROOT and GOPATH set in the environment. 6 7 After you set up the Go development environment, use `go get` to check out 8 `swarmkit`: 9 10 go get -d github.com/docker/swarmkit 11 12 This command installs the source repository into the `GOPATH`. 13 14 It is not mandatory to use `go get` to checkout the SwarmKit project. However, 15 for these instructions to work, you need to check out the project to the 16 correct subdirectory of the `GOPATH`: `$GOPATH/src/github.com/docker/swarmkit`. 17 18 ### Repeatable Builds 19 20 For the full development experience, one should `cd` into 21 `$GOPATH/src/github.com/docker/swarmkit`. From there, the regular `go` 22 commands, such as `go test`, should work per package (please see 23 [Developing](#developing) if they don't work). 24 25 Docker provides a `Makefile` as a convenience to support repeatable builds. 26 `make setup` installs tools onto the `GOPATH` for use with developing 27 `SwarmKit`: 28 29 make setup 30 31 Once these commands are available in the `GOPATH`, run `make` to get a full 32 build: 33 34 $ make 35 🐳 fmt 36 🐳 bin/swarmd 37 🐳 bin/swarmctl 38 🐳 bin/swarm-bench 39 🐳 bin/protoc-gen-gogoswarm 40 🐳 binaries 41 🐳 vet 42 🐳 lint 43 🐳 build 44 github.com/docker/swarmkit 45 github.com/docker/swarmkit/vendor/github.com/davecgh/go-spew/spew 46 github.com/docker/swarmkit/vendor/github.com/pmezard/go-difflib/difflib 47 github.com/docker/swarmkit/cmd/protoc-gen-gogoswarm 48 github.com/docker/swarmkit/cmd/swarm-bench 49 github.com/docker/swarmkit/cmd/swarmctl 50 github.com/docker/swarmkit/vendor/github.com/stretchr/testify/assert 51 github.com/docker/swarmkit/ca/testutils 52 github.com/docker/swarmkit/cmd/swarmd 53 github.com/docker/swarmkit/vendor/code.cloudfoundry.org/clock/fakeclock 54 github.com/docker/swarmkit/vendor/github.com/stretchr/testify/require 55 github.com/docker/swarmkit/manager/state/raft/testutils 56 github.com/docker/swarmkit/manager/testcluster 57 github.com/docker/swarmkit/protobuf/plugin/deepcopy/test 58 github.com/docker/swarmkit/protobuf/plugin/raftproxy/test 59 🐳 test 60 ? github.com/docker/swarmkit [no test files] 61 ? github.com/docker/swarmkit [no test files] 62 ok github.com/docker/swarmkit/agent 2.264s 63 ok github.com/docker/swarmkit/agent/exec 1.055s 64 ok github.com/docker/swarmkit/agent/exec/container 1.094s 65 ? github.com/docker/swarmkit/api [no test files] 66 ? github.com/docker/swarmkit/api/duration [no test files] 67 ? github.com/docker/swarmkit/api/timestamp [no test files] 68 ok github.com/docker/swarmkit/ca 15.634s 69 ... 70 ok github.com/docker/swarmkit/protobuf/plugin/raftproxy/test 1.084s 71 ok github.com/docker/swarmkit/protobuf/ptypes 1.025s 72 ? github.com/docker/swarmkit/version [no test files] 73 74 The above provides a repeatable build using the contents of the vendored 75 `./vendor` directory. This includes formatting, vetting, linting, building, 76 and testing. The binaries created will be available in `./bin`. 77 78 Several `make` targets are provided for common tasks. Please see the `Makefile` 79 for details. 80 81 ### Update vendored dependencies 82 83 To update dependency you need just change `vendor.conf` file and run `vndr` tool: 84 ``` 85 go get github.com/LK4D4/vndr 86 vndr 87 ``` 88 89 It's possible to update only one dependency: 90 ``` 91 vndr github.com/coreos/etcd v3.0.9 92 ``` 93 94 but it should be in sync with `vendor.conf`. 95 96 Also, you can update dependency from fork for testing: 97 ``` 98 vndr github.com/coreos/etcd <revision> https://github.com/LK4D4/etcd.git 99 ``` 100 101 ### Regenerating protobuf bindings 102 103 This requires that you have [Protobuf 3.x or 104 higher](https://developers.google.com/protocol-buffers/docs/downloads). Once 105 that is installed the bindings can be regenerated with: 106 107 ``` 108 make setup 109 make generate 110 ``` 111 112 NB: As of version 3.0.0-7 the Debian `protobuf-compiler` package lacks 113 a dependency on `libprotobuf-dev` which contains some standard proto 114 definitions, be sure to install both packages. This is [Debian bug 115 #842158](https://bugs.debian.org/842158). 116 117 ### Build in a container instead of your local environment 118 119 You can also choose to use a container to build SwarmKit and run tests. Simply 120 set the `DOCKER_SWARMKIT_USE_CONTAINER` environment variable to any value, 121 export it, then run `make` targets as you would have done within your local 122 environment. 123 124 Additionally, if your OS is not Linux, you might want to set and export the 125 `DOCKER_SWARMKIT_USE_DOCKER_SYNC` environment variable, which will make use of 126 [docker-sync](https://github.com/EugenMayer/docker-sync) to sync the code to 127 the container, instead of native mounted volumes.