Skip to content

Commit 2bb41f9

Browse files
authored
Merge pull request #33 from dpordomingo/docker-compose
Add docker-compose
2 parents a9fe459 + 36e318b commit 2bb41f9

File tree

5 files changed

+153
-37
lines changed

5 files changed

+153
-37
lines changed

Makefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ YARN := yarn --cwd $(FRONTEND_PATH)
2121
REMOVE := rm -rf
2222
MOVE := mv
2323
MKDIR := mkdir -p
24+
COMPOSE_UP := docker-compose
2425

2526
# Default rule
2627
all:
@@ -68,6 +69,16 @@ build-path:
6869

6970
serve: | front-build back-start
7071

72+
compose-serve: | require-repos-folder front-dependencies build
73+
GITBASEPG_REPOS_FOLDER=${GITBASEPG_REPOS_FOLDER} \
74+
$(COMPOSE_UP) -f docker-compose.yml -f docker-compose.build.yml up --force-recreate --build
75+
76+
require-repos-folder:
77+
@if [[ -z "$(GITBASEPG_REPOS_FOLDER)" ]]; then \
78+
echo "error. undefined 'GITBASEPG_REPOS_FOLDER' to be served under gitbase"; \
79+
exit 1; \
80+
fi
81+
$(MKDIR) $(GITBASEPG_REPOS_FOLDER)
7182

7283
# Backend
7384

@@ -115,6 +126,7 @@ front-lint:
115126

116127
front-build: build-path
117128
$(YARN) build
129+
$(REMOVE) $(BUILD_PATH)/public
118130
$(MOVE) $(FRONTEND_BUILD_PATH) $(BUILD_PATH)/public
119131

120132
front-fix-lint-errors:

docker-compose.build.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: '3.3'
2+
3+
services:
4+
playground:
5+
image: gitbase-playground-dev
6+
build: .

docker-compose.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
version: '3.3'
2+
3+
services:
4+
playground:
5+
image: "srcd/gitbase-playground"
6+
ports:
7+
- "8080:8080"
8+
environment:
9+
GITBASEPG_ENV: ${GITBASEPG_ENV}
10+
GITBASEPG_DB_CONNECTION: gitbase@tcp(gitbase:3306)/none?maxAllowedPacket=4194304
11+
gitbase:
12+
image: "srcd/gitbase"
13+
environment:
14+
BBLFSH_ENDPOINT: bblfsh:9432
15+
volumes:
16+
- ${GITBASEPG_REPOS_FOLDER}:/opt/repos
17+
bblfsh:
18+
image: "bblfsh/bblfshd"
19+
privileged: true
20+
volumes:
21+
- type: volume
22+
source: drivers
23+
target: /var/lib/bblfshd
24+
entrypoint: ["/bin/sh"]
25+
command:
26+
- "-c"
27+
- "bblfshd & sleep 5 && bblfshctl driver install --recommended && tail -f /dev/null"
28+
29+
volumes:
30+
drivers:

docs/quickstart-manually.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Quickstart
2+
3+
You can locally build and deploy `gitbase-playground` and its dependencies using [`docker-compose`](https://docs.docker.com/compose/install/)
4+
5+
If you prefer to run `gitbase-playground` with [`docker-compose`](https://docs.docker.com/compose) (without taking care of the app dependencies), you can follow [the playground compose quickstart](quickstart.md)
6+
7+
8+
## Run bblfsh and gitbase Dependencies
9+
10+
It is recommended to read about `bblfsh` and `gitbase` from its own documentation, but here is a small guide about how to run both easily:
11+
12+
Launch [bblfshd](https://github.com/bblfsh/bblfshd) and install the drivers. More info in the [bblfshd documentation](https://doc.bblf.sh/user/getting-started.html):
13+
14+
```bash
15+
$ docker run --privileged \
16+
--publish 9432:9432 \
17+
--volume /var/lib/bblfshd:/var/lib/bblfshd \
18+
--name bblfsh \
19+
bblfsh/bblfshd
20+
$ docker exec -it bblfsh \
21+
bblfshctl driver install --recommended
22+
```
23+
24+
[gitbase](https://github.com/src-d/gitbase) will serve git repositories, so it is needed to populate a directory with them:
25+
26+
```bash
27+
$ mkdir -p ~/gitbase/repos
28+
$ git clone [email protected]:src-d/go-git-fixtures.git ~/gitbase/repos/go-git-fixtures
29+
```
30+
31+
Install and run [gitbase](https://github.com/src-d/gitbase):
32+
33+
```bash
34+
$ docker run \
35+
--publish 3306:3306 \
36+
--link bblfsh \
37+
--volume ~/gitbase/repos:/opt/repos \
38+
--env BBLFSH_ENDPOINT=bblfsh:9432 \
39+
--name gitbase \
40+
srcd/gitbase:latest
41+
```
42+
43+
44+
## Run gitbase-playground
45+
46+
Once bblfsh and gitbase are running and accessible, you can serve the playground:
47+
48+
```bash
49+
$ docker run -d \
50+
--publish 8080:8080 \
51+
--link gitbase \
52+
--env GITBASEPG_ENV=dev \
53+
--env GITBASEPG_DB_CONNECTION="gitbase@tcp(gitbase:3306)/none?maxAllowedPacket=4194304" \
54+
--name gitbase_playground \
55+
srcd/gitbase-playground:latest
56+
```
57+
58+
Once the server is running –with its default values–, it will be accessible through: http://localhost:8080
59+
60+
You have more information about the [playground architecture](CONTRIBUTING.md#architecture), [development guides](CONTRIBUTING.md#development) and [configuration options](CONTRIBUTING.md#configuration) in the [CONTRIBUTING.md](CONTRIBUTING.md).
61+
62+
63+
## Run a Query
64+
65+
You will find more info about how to run queries using the playground API on the [rest-api guide](rest-api.md)

docs/quickstart.md

Lines changed: 40 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,65 @@
11
# Quickstart
22

3-
## Run bblfsh and gitbase Dependencies
3+
You can locally build and deploy `gitbase-playground` and its dependencies using [`docker-compose`](https://docs.docker.com/compose/install/).
4+
Docker compose will run three different containers: for the playground frontend itself, gitbase and bblfsh services. It will be the [latest gitbase version](https://hub.docker.com/r/srcd/gitbase/tags/) and [latest bblfsh version](https://hub.docker.com/r/bblfsh/bblfshd/tags/).
45

5-
It is recommended to read about `bblfsh` and `gitbase` from its own documentation, but here is a small guide about how to run both easily:
6+
If you preffer to run `gitbase-playground` dependencies manually, you can follow [the alternative playground quickstart](quickstart-manually.md)
67

7-
Launch [bblfshd](https://github.com/bblfsh/bblfshd) and install the drivers. More info in the [bblfshd documentation](https://doc.bblf.sh/user/getting-started.html):
8+
9+
## Download the project
810

911
```bash
10-
$ docker run --privileged
11-
--publish 9432:9432
12-
--volume /var/lib/bblfshd:/var/lib/bblfshd
13-
--name bblfsh
14-
bblfsh/bblfshd
15-
$ docker exec -it bblfsh
16-
bblfshctl driver install --recommended
12+
$ git clone [email protected]:src-d/gitbase-playground.git gitbase-playground
13+
$ cd gitbase-playground
1714
```
1815

19-
[gitbase](https://github.com/src-d/gitbase) will serve git repositories, so it is needed to populate a directory with them:
16+
This guide will assume you're running all commands from `gitbase-playground` sources directory
2017

21-
```bash
22-
$ mkdir -p ~/gitbase/repos
23-
$ git clone [email protected]:src-d/go-git-fixtures.git ~/gitbase/repos/go-git-fixtures
24-
```
2518

26-
Install and run [gitbase](https://github.com/src-d/gitbase):
19+
## Populate the database
20+
21+
It is needed to populate a directory with some git repositories to be served by [gitbase](https://github.com/src-d/gitbase) before running it.
22+
23+
example:
2724

2825
```bash
29-
# This quickstart is using a custom gitbase image until the official `srcd/gitbase` image is provided
30-
# See: https://github.com/src-d/gitbase/issues/262
31-
$ docker run
32-
--publish 3306:3306
33-
--link bblfsh
34-
--volume ~/gitbase/repos:/opt/repos
35-
--env BBLFSH_ENDPOINT=bblfsh:9432
36-
--name gitbase
37-
srcd/gitbase:latest
26+
$ git clone [email protected]:src-d/gitbase-playground.git ./repos/gitbase-playground
27+
$ git clone [email protected]:src-d/go-git-fixtures.git ./repos/go-git-fixtures
3828
```
3929

30+
Everytime you want to add a new repository to gitbase, the application should be restarted.
4031

41-
## Run gitbase-playground
4232

43-
Once bblfsh and gitbase are running and accessible, you can serve the playground:
33+
## Run the application
34+
35+
Run the [latest released version of the frontend](https://hub.docker.com/r/srcd/gitbase-playground/tags/):
4436

4537
```bash
46-
$ docker run -d
47-
--publish 8080:8080
48-
--link gitbase
49-
--env GITBASEPG_ENV=dev
50-
--env GITBASEPG_DB_CONNECTION="gitbase@tcp(gitbase:3306)/none?maxAllowedPacket=4194304"
51-
--name gitbase_playground
52-
srcd/gitbase-playground:latest
38+
$ GITBASEPG_REPOS_FOLDER=./repos docker-compose up --force-recreate
5339
```
5440

55-
Once the server is running –with its default values–, it will be accessible through: http://localhost:8080
41+
If you want to build and run the playground from sources instead of using the last released version you can do so:
5642

57-
You have more information about the [playground architecture](CONTRIBUTING.md#architecture), [development guides](CONTRIBUTING.md#development) and [configuration options](CONTRIBUTING.md#configuration) in the [CONTRIBUTING.md](CONTRIBUTING.md).
43+
<details>
44+
<pre>
45+
$ GITBASEPG_REPOS_FOLDER=./repos make compose-serve
46+
</pre>
47+
</details>
48+
49+
## Stop the Application
5850

51+
To kill the running containers just `Ctrl+C`
5952

60-
## Run a Query
53+
To delete the containers run `docker-compose rm -f`
54+
55+
56+
## Access to the Playground and Run a Query
57+
58+
Once the server is running &ndash;with its default values&ndash;, it will be accessible through: http://localhost:8080
6159

6260
You will find more info about how to run queries using the playground API on the [rest-api guide](rest-api.md)
61+
62+
63+
## More Info
64+
65+
You have more information about the [playground architecture](CONTRIBUTING.md#architecture), [development guides](CONTRIBUTING.md#development) and [configuration options](CONTRIBUTING.md#configuration) in the [CONTRIBUTING.md](CONTRIBUTING.md).

0 commit comments

Comments
 (0)