Skip to content

Commit c581d7a

Browse files
committed
more wip
Signed-off-by: Nell Shamrell <[email protected]>
1 parent 9d32cc1 commit c581d7a

File tree

3 files changed

+215
-33
lines changed

3 files changed

+215
-33
lines changed

README.md

Lines changed: 126 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,128 @@
11
# docker_dev_env_experiment
22

3-
## Current State
4-
This Docker compose file currently spins up two services in Docker containers:
5-
* Clearly Defined Website
6-
* Clearly Defined Service
7-
8-
### Pre-req
9-
* Local copy of Clearly Defined Website repo with `nell/dev-docker-file` branch checked out
10-
* Local copy of Clearly Defined Service repo with `nell/dev-docker-file` branch checked out
11-
12-
## Future State
13-
* Clearly Defined Crawler Container
14-
* Harvested Data Container that contains sample harvested data
15-
* Curated Data Container that contains sample curated data
3+
Hello everyone! The purpose of this repo is to give you an easy way to run a full
4+
development environment for Clearly Defined including:
5+
* [website](https://github.com/clearlydefined/website)
6+
* [service](https://github.com/clearlydefined/service)
7+
* [crawler](https://github.com/clearlydefined/crawler)
8+
* definitions and curations mongo DB databases
9+
* queues
10+
11+
We do this through running the various services in Docker.
12+
13+
We do this through [Docker](https://www.docker.com/) and [Docker Compose](https://docs.docker.com/compose/)
14+
15+
## Pre-reqs
16+
To run this environment, you need to install
17+
* [Docker](https://www.docker.com/)
18+
* [Docker Compose](https://docs.docker.com/compose/)
19+
20+
## Getting Started
21+
22+
Start off by cloning this repository.
23+
24+
```bash
25+
$ git clone https://github.com/clearlydefined/docker_dev_env_experiment
26+
```
27+
28+
Change into that directory:
29+
30+
```bash
31+
$ cd docker_dev_env_experiment
32+
```
33+
34+
I prefer to clone my copies of the ClearlyDefined repos into this directory as well
35+
36+
```bash
37+
$ git clone https://github.com/clearlydefined/website
38+
$ git clone https://github.com/clearlydefined/service
39+
$ git clone https://github.com/clearlydefined/crawler
40+
```
41+
42+
Alternately, you can edit the **docker-compose.yml** file to point to where you have those repos cloned on your local system:
43+
44+
**docker-compose.yml**
45+
```bash
46+
version: "3.8"
47+
services:
48+
web:
49+
build:
50+
context: <path-to-website-repo-on-your-system>
51+
dockerfile: DevDockerfile
52+
ports:
53+
- "3000:3000"
54+
stdin_open: true
55+
service:
56+
build:
57+
context: <path-to-service-repo-on-your-system>
58+
dockerfile: DevDockerfile
59+
ports:
60+
- "4000:4000"
61+
env_file: .env
62+
links:
63+
- clearlydefined_mongo_db
64+
crawler:
65+
context: <path-to-crawler-repo-on-your-system>
66+
env_file: .env
67+
ports:
68+
- "5000:5000"
69+
```
70+
71+
**NOTE**:
72+
While this is still in development, you need to check out the `nell/dev-docker-file` branch for each of the
73+
three repos.
74+
75+
### Setting up environmental variables
76+
77+
This environment handles environmental variables a little differently from the [historical Clearly Defined dev environment instructions](https://docs.clearlydefined.io/contributing-code).
78+
79+
The docker-compose.yml file loads environmental variables from a **.env** file.
80+
81+
To set this up, copy the **sample_env** file in this repo to **.env**
82+
83+
```bash
84+
$ cp sample_env .env
85+
```
86+
87+
And add in appropriate values to the .env file:
88+
89+
(You will need a [GitHub token](https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token) with minimal permissions)
90+
91+
(You can use the same GitHub token for both CURATION_GITHUB_TOKEN and CRAWLER_GITHUB_TOKEN)
92+
93+
94+
**.env**
95+
```
96+
# Curation GitHub Info
97+
CURATION_GITHUB_REPO="sample-curated-data"
98+
CURATION_GITHUB_BRANCH="master"
99+
CURATION_GITHUB_OWNER="clearlydefined"
100+
CURATION_GITHUB_REPO="curated-data-dev"
101+
CURATION_GITHUB_TOKEN="<Your GitHub Personal Access Token>
102+
103+
DEFINITION_STORE_PROVIDER="mongo"
104+
DEFINITION_MONGO_CONNECTION_STRING="mongodb://clearlydefined_mongo_db"
105+
DEFINITION_MONGO_DB_NAME="clearlydefined"
106+
DEFINITION_MONGO_COLLECTION_NAME="definitions-paged"
107+
108+
CRAWLER_GITHUB_TOKEN="<Your GitHub Personal Access Token>"
109+
```
110+
111+
Now, from withing your **docker_dev_env_experiment** directory, run:
112+
113+
```bash
114+
$ docker-compose build
115+
$ docker-compose up
116+
```
117+
118+
And head to http://localhost:3000 to see your running website UI along with some seeded data!
119+
120+
You can also query the service API with:
121+
122+
```bash
123+
curl http://localhost:4000
124+
```
125+
126+
## What You're Running
127+
128+
Now, let's go through what your are running, container by container.

docker-compose.yml

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ services:
66
dockerfile: DevDockerfile
77
ports:
88
- "3000:3000"
9-
env_file: .env
109
stdin_open: true
1110
service:
1211
build:
@@ -17,19 +16,11 @@ services:
1716
env_file: .env
1817
links:
1918
- clearlydefined_mongo_db
20-
# crawler:
21-
# build: ../crawler
22-
# env_file: .env
23-
# ports:
24-
# - "5000:5000"
25-
# curations_mongo_db:
26-
# image: "mongo:latest"
27-
# ports:
28-
# - "27017:27017"
29-
# environment:
30-
# - MONGO_INITDB_DATABASE=curations-dev-docker
31-
# - MONGO_INITDB_ROOT_USERNAME=admin
32-
# - MONGO_INITDB_ROOT_PASSWORD=secret
19+
crawler:
20+
build: ../crawler
21+
env_file: .env
22+
ports:
23+
- "5000:5000"
3324
clearlydefined_mongo_db:
3425
image: "mongo:latest"
3526
ports:

walkthrough.md

Lines changed: 84 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,17 +180,95 @@ services:
180180
env_file: .env
181181
ports:
182182
- "4000:4000"
183-
curations_mongo_db:
183+
clearlydefined_mongo_db:
184184
image: "mongo:latest"
185185
ports:
186186
- "27017:27017"
187-
environment:
188-
- MONGO_INITDB_DATABASE=curations-dev-docker
189-
- MONGO_INITDB_ROOT_USERNAME=admin
190-
- MONGO_INITDB_ROOT_PASSWORD=secret
191187
```
192188

193-
And let's add the appropriate info to the .env file:
189+
### Linking the database to our service
190+
191+
Our service will be communicating with our mongo database. Let's link them by adding this line to the
192+
service in our compose file
193+
194+
**docker-compose.yml**
195+
```
196+
(...)
197+
service:
198+
build:
199+
context: ./service
200+
dockerfile: DevDockerfile
201+
env_file: .env
202+
ports:
203+
- "4000:4000"
204+
links:
205+
- clearlydefined_mongo_db
206+
(...)
207+
```
208+
209+
So at this point, your whole docker-compose file should look like this:
210+
211+
**docker-compose.yml**
212+
```
213+
version: "3.8"
214+
services:
215+
web:
216+
build:
217+
context: ./website
218+
dockerfile: DevDockerfile
219+
ports:
220+
- "3000:3000"
221+
stdin_open: true
222+
service:
223+
build:
224+
context: ./service
225+
dockerfile: DevDockerfile
226+
env_file: .env
227+
ports:
228+
- "4000:4000"
229+
clearlydefined_mongo_db:
230+
image: "mongo:latest"
231+
ports:
232+
- "27017:27017"
233+
```
234+
235+
### Seeding data into the definitions database
236+
237+
In order for this database to be useful, it needs to have some data in it. We will create another container
238+
to seed sample data into our database.
239+
240+
First, from within your clearlydefined directory, go ahead and create a new directory:
241+
242+
```bash
243+
$ mkdir mongo_seed
244+
```
245+
246+
And create a new
247+
248+
```
249+
version: "3.8"
250+
services:
251+
web:
252+
build:
253+
context: ./website
254+
dockerfile: DevDockerfile
255+
ports:
256+
- "3000:3000"
257+
stdin_open: true
258+
service:
259+
build:
260+
context: ./service
261+
dockerfile: DevDockerfile
262+
env_file: .env
263+
ports:
264+
- "4000:4000"
265+
clearlydefined_mongo_db:
266+
image: "mongo:latest"
267+
ports:
268+
- "27017:27017"
269+
```
270+
271+
194272

195273
**.env**
196274
```bash

0 commit comments

Comments
 (0)