Skip to content

Commit 9a885b0

Browse files
authored
Merge pull request #172 from carlosms/improve-docs
Rearrange and improve docs
2 parents 96605ad + 1d3c9b0 commit 9a885b0

File tree

5 files changed

+162
-199
lines changed

5 files changed

+162
-199
lines changed

README.md

Lines changed: 48 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,88 @@
11
[![Build Status](https://travis-ci.org/src-d/gitbase-playground.svg)](https://travis-ci.org/src-d/gitbase-playground)
22
[![codecov.io](https://codecov.io/github/src-d/gitbase-playground/coverage.svg)](https://codecov.io/github/src-d/gitbase-playground)
3-
![unstable](https://svg-badge.appspot.com/badge/stability/unstable?a)
43

54
# Gitbase Playground
65

7-
Web application to query git repositories using SQL. Powered by [gitbase](https://github.com/src-d/gitbase).
6+
Web application to query Git repositories using SQL. Powered by [gitbase](https://github.com/src-d/gitbase), it allows to perform SQL queries on the Git history and the [Universal AST](https://doc.bblf.sh/) of the code itself.
87

98
![Screenshot](.github/screenshot.png?raw=true)
109

11-
1210
# Usage
1311

14-
## Dependencies
12+
## With Docker Compose
13+
14+
The easiest way to run Gitbase Playground and its dependencies is using [Docker Compose](https://docs.docker.com/compose/install/).
1515

16-
The playground will run the queries against a [gitbase](https://github.com/src-d/gitbase) server, and will request UASTs to a [bblfsh](https://doc.bblf.sh/) server; both should be accessible for the playground; you can check its default [configuration values](docs/CONTRIBUTING.md#configuration).
16+
The first step is to populate a directory with some Git repositories to be served by gitbase before running it. For example:
1717

18+
```bash
19+
$ mkdir $HOME/repos
20+
$ cd $HOME/repos
21+
$ git clone [email protected]:src-d/gitbase.git
22+
$ git clone [email protected]:bblfsh/bblfshd.git
23+
$ git clone [email protected]:src-d/gitbase-playground.git
24+
```
1825

19-
## Run the Playground
26+
Next you will need to download the `docker-compose.yml` file from this repository and run `docker-compose`. This tool will run three different containers: the playground frontend itself, gitbase, and bblfshd. To kill the running containers use `Ctrl+C`.
27+
28+
```bash
29+
$ wget https://raw.githubusercontent.com/src-d/gitbase-playground/master/docker-compose.yml
30+
$ docker-compose pull
31+
$ GITBASEPG_REPOS_FOLDER=$HOME/repos docker-compose up --force-recreate
32+
```
2033

21-
You can run the app from a docker image, a released binary or installing and building the project.
34+
The server should be now available at [http://localhost:8080](http://localhost:8080).
2235

23-
Once the server is running –with its default values–, it will be accessible through: http://localhost:8080
36+
## Without Docker Compose
2437

25-
Read [more about how to run bblfsh and gitbase dependencies](docs/quickstart.md).
38+
The playground will run the queries against a [gitbase](https://docs.sourced.tech/gitbase) server, and will request UASTs to a [bblfsh](https://doc.bblf.sh/) server. Make sure both are properly configured.
2639

27-
### Run with Docker
40+
Then you can choose to run the Gitbase Playground either as a docker container, or as a binary.
41+
42+
### As a Docker
2843

2944
```bash
3045
$ docker pull srcd/gitbase-playground:latest
3146
$ docker run -d \
3247
--publish 8080:8080 \
33-
--link gitbase \
34-
--env GITBASEPG_ENV=dev \
35-
--env GITBASEPG_DB_CONNECTION="root@tcp(gitbase:3306)/none?maxAllowedPacket=4194304" \
36-
--name gitbasePlayground \
48+
--env GITBASEPG_DB_CONNECTION="root@tcp(<gitbase-ip>:3306)/none" \
49+
--env GITBASEPG_BBLFSH_SERVER_URL="<bblfshd-ip>:9432" \
3750
srcd/gitbase-playground:latest
3851
```
3952

53+
### As a Binary
4054

41-
### Run the Binary
42-
43-
Download a binary from our [releases section](https://github.com/src-d/gitbase-playground/releases), and run it:
55+
Download the binary from our [releases section](https://github.com/src-d/gitbase-playground/releases), and run it:
4456

4557
```bash
46-
$ /download/path/gitbase-playground
58+
$ export GITBASEPG_DB_CONNECTION="root@tcp(<gitbase-ip>:3306)/none"
59+
$ export GITBASEPG_BBLFSH_SERVER_URL="<bblfshd-ip>:9432"
60+
$ ./gitbase-playground
4761
```
4862

63+
# Configuration
4964

50-
# Contribute
65+
Any of the previous execution methods accept configuration through the following environment variables.
5166

52-
[Contributions](https://github.com/src-d/gitbase-playground/issues) are more than welcome, if you are interested please take a look to our [Contributing Guidelines](docs/CONTRIBUTING.md). You have more information on how to run it locally for [development purposes here](docs/CONTRIBUTING.md#development).
67+
| Variable | Default value | Meaning |
68+
| -- | -- | -- |
69+
| `GITBASEPG_HOST` | `0.0.0.0` | IP address to bind the HTTP server |
70+
| `GITBASEPG_PORT` | `8080` | Port to bind the HTTP server |
71+
| `GITBASEPG_SERVER_URL` | | URL used to access the application in the form `HOSTNAME[:PORT]`. Leave it unset to allow connections from any proxy or public address |
72+
| `GITBASEPG_DB_CONNECTION` | `root@tcp(localhost:3306)/none?maxAllowedPacket=4194304` | gitbase connection string |
73+
| `GITBASEPG_BBLFSH_SERVER_URL` | `127.0.0.1:9432` | Address where bblfsh server is listening |
74+
| `GITBASEPG_ENV` | `production` | Sets the log level. Use `dev` to enable debug log messages |
75+
| `GITBASEPG_SELECT_LIMIT` | `100` | Default `LIMIT` forced on all the SQL queries done from the UI |
76+
| `GITBASEPG_FOOTER_HTML` | | Allows to add any custom html to the page footer. It must be a string encoded in base64. Use it, for example, to add your analytics tracking code snippet |
5377

78+
# Contribute
79+
80+
[Contributions](https://github.com/src-d/gitbase-playground/issues) are more than welcome, if you are interested please take a look to our [Contributing Guidelines](docs/CONTRIBUTING.md). There you will also find information on how to build and run the project from sources.
5481

5582
# Code of Conduct
5683

5784
All activities under source{d} projects are governed by the [source{d} code of conduct](https://github.com/src-d/guide/blob/master/.github/CODE_OF_CONDUCT.md).
5885

59-
60-
## License
86+
# License
6187

6288
GPL v3.0, see [LICENSE](LICENSE)

docs/CONTRIBUTING.md

Lines changed: 110 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,158 @@
1-
# Contribution Guidelines
1+
# Gitbase Playground Contribution Guidelines
22

33
As all source{d} projects, this project follows the
44
[source{d} Contributing Guidelines](https://github.com/src-d/guide/blob/master/engineering/documents/CONTRIBUTING.md).
55

6+
In addition to those guidelines, this document describes how to build and run the application for development purposes.
67

7-
## Additional Contribution Guidelines
8+
# Requirements
89

9-
In addition to the [source{d} Contributing Guidelines](https://github.com/src-d/guide/blob/master/engineering/documents/CONTRIBUTING.md),
10-
this project follows the guidelines described below.
10+
Refer to the main [README](../README.md) for the common requirements and configuration environment variables.
1111

12+
Make sure you also satisfy these requirements:
13+
- [Install Go](https://golang.org/doc/install) and [configure the $GOPATH](https://github.com/golang/go/wiki/SettingGOPATH).
14+
- This project should be cloned in `$GOPATH/github.com/src-d/gitbase-playground`.
15+
- Install [Node.js](https://nodejs.org) and [Yarn](https://yarnpkg.com/en/docs/install).
1216

13-
# Architecture
17+
## Run bblfsh and gitbase Dependencies
18+
19+
As with a normal deployment, if you don't use Docker Compose you will need to configure a [gitbase](https://docs.sourced.tech/gitbase) server, and a [bblfsh](https://doc.bblf.sh/) server. It is recommended to read their documentation, but here is a quick guide on how to run both as docker containers.
20+
21+
Launch bblfshd and install the required drivers:
22+
23+
```bash
24+
$ docker run \
25+
--privileged \
26+
--publish 9432:9432 \
27+
--volume /var/lib/bblfshd:/var/lib/bblfshd \
28+
--name bblfsh \
29+
bblfsh/bblfshd
30+
$ docker exec -it bblfsh bblfshctl driver install --recommended
31+
```
1432

15-
The application is a go binnary that serves the statics and the API used for the UI.
33+
gitbase will serve Git repositories, so you will need to to populate a directory with them:
1634

17-
The statics (`html`, `js` and `css`) are generated by `yarn`, embedded in the go binary using bindata, and served from the binary itself.
35+
```bash
36+
$ mkdir $HOME/repos
37+
$ cd $HOME/repos
38+
$ git clone [email protected]:src-d/gitbase.git
39+
$ git clone [email protected]:bblfsh/bblfshd.git
40+
$ git clone [email protected]:src-d/gitbase-playground.git
41+
```
1842

19-
There are two main different ways to run the app:
43+
Launch gitbase:
44+
45+
```bash
46+
$ docker run \
47+
--publish 3306:3306 \
48+
--link bblfsh \
49+
--volume $HOME/repos:/opt/repos \
50+
--env BBLFSH_ENDPOINT=bblfsh:9432 \
51+
--name gitbase \
52+
srcd/gitbase
53+
```
2054

21-
- using released artifacts, as [listed in the README.md](../README.md#run-the-playground)
22-
- serving the app for development purposes, [building and running it from sources](#run-from-sources)
55+
# Architecture
2356

57+
The application is a Go binary that serves the static files and the API used for the UI.
2458

25-
# Configuration
59+
The static files (`html`, `js`, and `css`) are generated by `yarn`, embedded in the Go binary using `go-bindata`, and served from the binary itself.
2660

27-
| Variable | Required | Default value | Meaning |
28-
| -- | -- | -- | -- |
29-
| `GITBASEPG_HOST` | | `0.0.0.0` | IP address to bind the HTTP server |
30-
| `GITBASEPG_PORT` | | `8080` | Port address to bind the HTTP server |
31-
| `GITBASEPG_SERVER_URL` | | `<GITBASEPG_HOST>:<GITBASEPG_PORT>` | URL used to access the application (i.e. public hostname) |
32-
| `GITBASEPG_DB_CONNECTION` | | `root@tcp(localhost:3306)/none?maxAllowedPacket=4194304` | gitbase connection string |
33-
| `GITBASEPG_BBLFSH_SERVER_URL` | | `127.0.0.1:9432` | Address where bblfsh server is listening |
34-
| `GITBASEPG_ENV` | | `production` | Sets the log level. Use `dev` to enable debug log messages |
35-
| `FOOTER_HTML` | | | Allows to add any custom html to the page footer. It must be encoded in base64 |
61+
# API
3662

63+
The backend API is documented in the [rest API guide](rest-api.md)
3764

3865
# Development
3966

40-
## Requirements
67+
Each one of the following sections describes an alternative method to run the project from sources. You may use the one that suits your needs.
4168

42-
You should already have [Go installed](https://golang.org/doc/install#install), and properly [configured the $GOPATH](https://github.com/golang/go/wiki/SettingGOPATH)
69+
They all require the project is cloned into your `$GOPATH`.
4370

71+
```bash
72+
$ go get -d -u github.com/src-d/gitbase-playground/...
73+
$ cd $GOPATH/github.com/src-d/gitbase-playground
4474
```
45-
go version; # prints your go version
46-
go env GOPATH; # prints your $GOPATH path
75+
76+
## Run from Sources
77+
78+
The following command will build the frontend and serve it from the Go backend:
79+
80+
```bash
81+
$ make serve
4782
```
4883

49-
The project must be under $GOPATH, as required by the Go tooling.
50-
You should be able to navigate into the source code by running:
84+
This will start a server locally, which you can access at [http://localhost:8080](http://localhost:8080).
85+
86+
## Run Using webpack Hot Module Replacement
87+
88+
Instead of rebuilding the frontend and restarting the backend every time you do a change, you may instead run the backend to provide the API, and use webpack to serve the frontend.
5189

90+
In one terminal run the Go backend:
91+
92+
```bash
93+
$ GITBASEPG_ENV=dev go run cmd/gitbase-playground/main.go
5294
```
53-
cd $GOPATH/src/github.com/src-d/gitbase-playground
95+
96+
In another terminal, run the frontend:
97+
```bash
98+
$ yarn --cwd frontend install
99+
$ yarn --cwd frontend start
54100
```
55101

56-
You need also [Yarn v1.x.x installed](https://yarnpkg.com/en/docs/install)
102+
## Run with Docker Compose from Sources
103+
104+
The file `docker-compose.build.yml` overrides the default compose file. Using it a new docker image, `gitbase-playground-dev`, will be created from the current sources.
57105

106+
```bash
107+
$ make dependencies
108+
$ make packages
109+
$ GITBASEPG_REPOS_FOLDER=$HOME/repos docker-compose \
110+
-f docker-compose.yml -f docker-compose.build.yml \
111+
up --force-recreate --build
58112
```
59-
yarn --version; # prints your Yarn version
113+
114+
For convenience you may run the same commands with:
115+
116+
```bash
117+
$ make compose-serve
60118
```
61119

120+
## Build a Docker Container
62121

63-
## Run from Sources
122+
These commands will build a stand-alone docker image, that will require external gitbase and bblfshd servers.
64123

65-
You need to satisfy all [project requirements](#requirements), and then run:
124+
```bash
125+
$ make dependencies
126+
$ make packages
127+
$ make docker-build
128+
```
129+
130+
# Testing
131+
132+
## Lint
133+
134+
Use `make lint` to make sure the code follows the project's coding style.
66135

67136
```bash
68-
$ go get -d -u github.com/src-d/gitbase-playground/...
69-
$ cd $GOPATH/github.com/src-d/gitbase-playground
70-
$ make serve
137+
$ make lint
71138
```
72139

73-
This will start a server locally, which you can access on [http://localhost:8080](http://localhost:8080)
140+
## Unit Tests
74141

142+
The command `make test` will run JavaScript and Go tests.
143+
144+
```bash
145+
$ make test
146+
```
75147

76148
## Integration Tests
77149

78-
The integration tests require that `gitbase` and `bblfshd` are running and available for the playground.
150+
Use the `GITBASEPG_INTEGRATION_TESTS=true` environment variable with the same `make test` command.
151+
152+
The integration tests require that `gitbase` and `bblfshd` are running and reachable. See the [Requirements section](#requirements) above for more details.
79153

80154
It is also required to configure the running `gitbase` to serve a copy of the `https://github.com/src-d/gitbase-playground` repository.
81155

82156
```bash
83-
$ docker run -d --name bblfshd --privileged -p "9432:9432" bblfsh/bblfshd
84-
$ docker exec -it bblfshd bblfshctl driver install --recommended
85-
$ mkdir $HOME/repos
86-
$ git clone https://github.com/src-d/gitbase-playground.git $HOME/repos/gitbase-playground
87-
$ docker run -d --name gitbase -p "3306:3306" -e "BBLFSH_ENDPOINT=bblfshd:9432" --volume $HOME/repos:/opt/repos --link bblfshd srcd/gitbase
88157
$ GITBASEPG_INTEGRATION_TESTS=true make test
89158
```

docs/quickstart-manually.md

Lines changed: 0 additions & 66 deletions
This file was deleted.

0 commit comments

Comments
 (0)