docs: Update command in BUILDING after moving to go modules

Signed-off-by: Shengjing Zhu <zhsj@debian.org>
This commit is contained in:
Shengjing Zhu 2020-12-21 00:01:51 +08:00
parent dc207b654d
commit 13917b03dc

View File

@ -22,12 +22,12 @@ To build the `containerd` daemon, and the `ctr` simple test client, the followin
First you need to setup your Go development environment. You can follow this First you need to setup your Go development environment. You can follow this
guideline [How to write go code](https://golang.org/doc/code.html) and at the guideline [How to write go code](https://golang.org/doc/code.html) and at the
end you need to have `GOPATH` and `GOROOT` set in your environment. end you have `go` command in your `PATH`.
At this point you can use `go` to checkout `containerd` in your `GOPATH`: You need `git` to checkout the source code:
```sh ```sh
go get github.com/containerd/containerd git clone https://github.com/containerd/containerd
``` ```
For proper results, install the `protoc` release into `/usr/local` on your build system. For example, the following commands will download and install the 3.11.4 release for a 64-bit Linux host: For proper results, install the `protoc` release into `/usr/local` on your build system. For example, the following commands will download and install the 3.11.4 release for a 64-bit Linux host:
@ -63,19 +63,15 @@ correct version of `runc` installed.
For the quick and dirty installation, you can use the following: For the quick and dirty installation, you can use the following:
go get github.com/opencontainers/runc ```
git clone https://github.com/opencontainers/runc
This is not recommended, as the generated binary will not have version cd runc
information. Instead, cd into the source directory and use make to build and make
install the binary: sudo make install
```
cd $GOPATH/src/github.com/opencontainers/runc
make
make install
Make sure to follow the guidelines for versioning in [RUNC.md](RUNC.md) for the Make sure to follow the guidelines for versioning in [RUNC.md](RUNC.md) for the
best results. Some pointers on proper build tag setupVersion mismatches can best results.
result in undefined behavior.
## Build containerd ## Build containerd
@ -83,7 +79,7 @@ result in undefined behavior.
can run: can run:
``` ```
cd $GOPATH/src/github.com/containerd/containerd cd containerd
make make
``` ```
@ -111,7 +107,10 @@ make generate
> For example, adding `BUILDTAGS=no_btrfs` to your environment before calling the **binaries** > For example, adding `BUILDTAGS=no_btrfs` to your environment before calling the **binaries**
> Makefile target will disable the btrfs driver within the containerd Go build. > Makefile target will disable the btrfs driver within the containerd Go build.
Vendoring of external imports uses the [`vndr` tool](https://github.com/LK4D4/vndr) which uses a simple config file, `vendor.conf`, to provide the URL and version or hash details for each vendored import. After modifying `vendor.conf` run the `vndr` tool to update the `vendor/` directory contents. Combining the `vendor.conf` update with the changeset in `vendor/` after running `vndr` should become a single commit for a PR which relies on vendored updates. Vendoring of external imports uses the [Go Modules](https://golang.org/ref/mod#vendoring). You need
to use `go mod` command to modify the dependencies. After modifition, you should run `go mod tidy`
and `go mod vendor` to ensure the `go.mod`, `go.sum` files and `vendor` directory are up to date.
Changes to these files should become a single commit for a PR which relies on vendored updates.
Please refer to [RUNC.md](/RUNC.md) for the currently supported version of `runc` that is used by containerd. Please refer to [RUNC.md](/RUNC.md) for the currently supported version of `runc` that is used by containerd.
@ -131,6 +130,8 @@ make EXTRA_FLAGS="-buildmode pie" \
# Via Docker container # Via Docker container
The following instructions assume you are at the parent directory of containerd source directory.
## Build containerd ## Build containerd
You can build `containerd` via a Linux-based Docker container. You can build `containerd` via a Linux-based Docker container.
@ -148,7 +149,7 @@ containerd source root directory you can run the following command:
```sh ```sh
docker run -it \ docker run -it \
-v ${PWD}:/go/src/github.com/containerd/containerd \ -v ${PWD}/containerd:/go/src/github.com/containerd/containerd \
-e GOPATH=/go \ -e GOPATH=/go \
-w /go/src/github.com/containerd/containerd containerd/build sh -w /go/src/github.com/containerd/containerd containerd/build sh
``` ```
@ -164,10 +165,10 @@ You are now ready to [build](#build-containerd):
## Build containerd and runc ## Build containerd and runc
To have complete core container runtime, you will need both `containerd` and `runc`. It is possible to build both of these via Docker container. To have complete core container runtime, you will need both `containerd` and `runc`. It is possible to build both of these via Docker container.
You can use `go` to checkout `runc` in your `GOPATH`: You can use `git` to checkout `runc`:
```sh ```sh
go get github.com/opencontainers/runc git clone https://github.com/opencontainers/runc
``` ```
We can build an image from this `Dockerfile`: We can build an image from this `Dockerfile`:
@ -187,8 +188,8 @@ Let's suppose you build an image called `containerd/build` from the above Docker
```sh ```sh
docker run -it --privileged \ docker run -it --privileged \
-v /var/lib/containerd \ -v /var/lib/containerd \
-v ${GOPATH}/src/github.com/opencontainers/runc:/go/src/github.com/opencontainers/runc \ -v ${PWD}/runc:/go/src/github.com/opencontainers/runc \
-v ${GOPATH}/src/github.com/containerd/containerd:/go/src/github.com/containerd/containerd \ -v ${PWD}/containerd:/go/src/github.com/containerd/containerd \
-e GOPATH=/go \ -e GOPATH=/go \
-w /go/src/github.com/containerd/containerd containerd/build sh -w /go/src/github.com/containerd/containerd containerd/build sh
``` ```