You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+81-31Lines changed: 81 additions & 31 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,48 +4,98 @@ Microservice to manage CRUD operations for all things Projects.
4
4
5
5
### Note : Steps mentioned below are best to our capability as guide for local deployment, however, we expect from contributor, being a developer, to resolve run-time issues (e.g. OS and node version issues etc), if any.
6
6
7
-
###Local Development
7
+
## Local Development
8
8
9
-
* We use docker-compose for running dependencies locally. Instructions for Docker compose setup - https://docs.docker.com/compose/install/
9
+
### Requirements
10
+
11
+
*[docker-compose](https://docs.docker.com/compose/install/) - We use docker-compose for running dependencies locally.
10
12
* Nodejs 8.9.4 - consider using [nvm](https://github.com/creationix/nvm) or equivalent to manage your node version
Copy config/sample.local.js as config/local.js, update the properties and according to your env setup
22
-
23
-
#### Database
24
-
Once you start your PostgreSQL database through docker, it will create a projectsdb.
25
-
*To create tables - note this will drop tables if they already exist*
26
-
```
27
-
NODE_ENV=development npm run sync:db
28
-
```
29
14
30
-
#### Redis
31
-
Docker compose command will start a local redis instance as well. You should be able to connect to this instance using url `$(docker-machine ip):6379`
15
+
### Steps to run locally
16
+
1. Install node dependencies
17
+
```bash
18
+
npm install
19
+
```
20
+
21
+
* Run docker with dependant services
22
+
```bash
23
+
cd local/
24
+
docker-compose up
25
+
```
26
+
This will run several services locally:
27
+
-`postgres`
28
+
-`elasticsearch`
29
+
-`rabbitmq`
30
+
-`mock-services` - mocks some Topcoder API
31
+
32
+
*NOTE: In production these dependencies / services are hosted & managed outside tc-projects-service.*
33
+
34
+
* Local config
35
+
```bash
36
+
# in the tc-project-service root folder, not inside local/ as above
37
+
cp config/sample.local.js config/local.js
38
+
```
39
+
Copy `config/sample.local.js` as `config/local.js`.<br>
40
+
As project service depend on many third-party services we have to config how to access them. Some services are run locally and some services are used from Topcoder DEV environment. `config/local.js` has a prepared configuration which would replace values no matter what `NODE_ENV` value is.
41
+
42
+
**IMPORTANT** This configuration file assumes that services run by docker use domain `dockerhost`. Depend on your system you have to make sure that domain `dockerhost` points to the IP address of docker.
43
+
For example, you can add a the next line to your `/etc/hosts` file, if docker is run on IP `127.0.0.1`.
44
+
```
45
+
127.0.0.1 dockerhost
46
+
```
47
+
Alternatively, you may update `config/local.js` and replace `dockerhost` with your docker IP address.<br>
48
+
You may try using command `docker-machine ip` to get your docker IP, but it works not for all systems.
49
+
50
+
* Create tables in DB
51
+
```bash
52
+
NODE_ENV=development npm run sync:db
53
+
```
54
+
This command will crate tables in `postgres` db.
55
+
56
+
*NOTE: this will drop tables if they already exist.*
57
+
58
+
* Sync ES indices
59
+
```bash
60
+
NODE_ENV=development npm run sync:es
61
+
```
62
+
Helper script to sync the indices and mappings with the elasticsearch.
63
+
64
+
*NOTE: This will first clear all the indices and than recreate them. So use with caution.*
65
+
66
+
* Run
67
+
```bash
68
+
npm run start:dev
69
+
```
70
+
Runs the Project Service using nodemon, so it would be restarted after any of the files is updated.
71
+
The project service will be served on `http://localhost:8001`.
32
72
33
-
#### Elasticsearch
34
-
Docker compose includes elasticsearch instance as well. It will open ports 9200 & 9300 (kibana)
35
-
36
-
#### Sync indices and mappings
73
+
### Import sample metadata
74
+
```bash
75
+
node migrations/seedMetadata.js
76
+
```
77
+
To create sample metadata entries (duplicate what is currently in development environment).
37
78
38
-
There is a helper script to sync the indices and mappings with the elasticsearch.
79
+
### Run Connect App with Project Service locally
39
80
40
-
Run `npm run sync:es` from the root of project to execute the script.
81
+
To be able to run [Connect App](https://github.com/appirio-tech/connect-app) with the local setup of Project Service we have to do two things:
82
+
1. Configurate Connect App to use locally deployed Project service inside `connect-app/config/constants/dev.js` set
41
83
42
-
> NOTE: This will first clear all the indices and than recreate them. So use with caution.
84
+
```js
85
+
PROJECTS_API_URL:'http://localhost:8001'
86
+
```
87
+
2. Bypass token validation in Project Service.
43
88
44
-
**NOTE**: In production these dependencies / services are hosted & managed outside tc-projects-service.
89
+
In `tc-project-service/node_modules/tc-core-library-js/lib/auth/verifier.js` add this to line 23:
90
+
```js
91
+
callback(undefined, decodedToken.payload);
92
+
return;
93
+
```
94
+
Connect App when making requests to the Project Service uses token retrieved from the Topcoder service deployed online. Project Service validates the token. For this purpose Project Service have to know the `secret` which has been used to generate the token. But we don't know the `secret` which is used by Topcoder for both DEV and PROD environment. So to bypass token validation we change these lines in the auth library.
45
95
46
-
### Import sample metadata
96
+
*NOTE: this change only let us bypass validation during local development process*.
47
97
48
-
To create sample metadata entries (duplicate what is currently in development environment) run `node migrations/seedMetadata.js`
98
+
3. Restart both Connect App and Project Service if they were running.
0 commit comments