|
1 |
| -# Build and Test in Docker Containers |
| 1 | +# GoHive: Build and Test in Docker Containers |
2 | 2 |
|
3 | 3 | GoHive is a Hive driver for Go's database API. To build and test it, we need not only the building tools but also Hive. For the convenience of contributors, we install all tools into a Docker image so could we run and test in a Docker container.
|
4 | 4 |
|
5 | 5 | The general usage is that we check out the source code on the host computer, then we start a Docker container and run building tools in the container. The critical point is that we map the source code directory into the container. Feel free to use any of your favorite editor, Emacs, Vim, Eclipse, installed and running on the host.
|
6 | 6 |
|
| 7 | + |
7 | 8 | ## Check out the Source Code
|
8 | 9 |
|
9 |
| -The following command |
| 10 | +Run the following command to clone GoHive to `$GOPATH/src/sqlflow.org/gohive` on your host computer: |
10 | 11 |
|
11 | 12 | ```bash
|
12 |
| -go get github.com/sql-machine-learning/gohive |
| 13 | +go get sqlflow.org/gohive |
13 | 14 | ```
|
14 | 15 |
|
15 |
| -clones GoHive to `$GOPATH/src/github.com/sql-machine-learning/gohive`. |
16 | 16 |
|
17 | 17 | ## Build the Docker Image
|
18 | 18 |
|
19 |
| -The following command |
| 19 | +Run the following command in the `/docker` directory to create the Docker image `gohive:dev`: |
20 | 20 |
|
21 | 21 | ```bash
|
22 |
| -docker build -t gohive:dev dockerfile |
| 22 | +cd gohive/docker |
| 23 | +docker build -t gohive:dev . |
23 | 24 | ```
|
24 | 25 |
|
25 |
| -in the Dockerfile directory creates the Docker image `gohive:dev`. |
26 | 26 |
|
27 |
| -## Build and Test in a Container |
| 27 | +## Build and Test GoHive |
28 | 28 |
|
29 |
| -The following command starts a container and maps the `$GOPATH` directory on the host to the `/go` directory in the container. Please be aware that the Dockerfile configures `/go` as the `$GOPATH` in the container. |
| 29 | +The following command starts a container with Hive running inside, so could we build and test GoHive: |
30 | 30 |
|
31 | 31 | ```bash
|
32 | 32 | docker run --rm -it -v $GOPATH:/go \
|
33 | 33 | -w /go/src/github.com/sql-machine-learning/gohive \
|
34 | 34 | gohive:dev bash
|
35 | 35 | ```
|
36 | 36 |
|
37 |
| -After the container prints many lines of logs showing that the Hive server is starting, we can build and run tests: |
| 37 | +The `-v` option maps `$GOPATH` on the host to `/go` in the container. Please be aware that the Dockerfile configures `/go` as the `$GOPATH` in the container. After many lines of logs scroll up while the Hive server starts, there comes the shell prompt, where we can run the following command to build and run tests: |
38 | 38 |
|
39 |
| -``` |
40 |
| -go build |
| 39 | +```bash |
41 | 40 | go test -v
|
42 | 41 | ```
|
0 commit comments