Skip to content

Commit 3accea7

Browse files
documentation updates
1 parent e3ad673 commit 3accea7

File tree

4 files changed

+93
-2
lines changed

4 files changed

+93
-2
lines changed

README.md

+78
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,84 @@ This script will load the data from `scripts/data` directory into ES
115115
npm run start
116116
```
117117

118+
### Local Deployment
119+
0. Make sure to use Node v10+ by command `node -v`. We recommend using [NVM](https://github.com/nvm-sh/nvm) to quickly switch to the right version:
120+
121+
```bash
122+
nvm use
123+
```
124+
125+
1. 📦 Install npm dependencies
126+
127+
```bash
128+
npm install
129+
```
130+
131+
2. ⚙ Local config
132+
In the `submissions-api` root directory create `.env` file with the next environment variables. Values for **Auth0 config** should be shared with you on the forum.<br>
133+
```bash
134+
# AWS related config
135+
AWS_ACCESS_KEY_ID=
136+
AWS_SECRET_ACCESS_KEY=
137+
AWS_REGION=
138+
S3_BUCKET=
139+
ARTIFACT_BUCKET=
140+
141+
# Auth0 config
142+
AUTH0_URL=
143+
AUTH0_PROXY_SERVER_URL=
144+
TOKEN_CACHE_TIME=
145+
AUTH0_AUDIENCE=
146+
AUTH0_CLIENT_ID=
147+
AUTH0_CLIENT_SECRET=
148+
149+
# Locally deployed services (via docker-compose)
150+
ES_HOST=localhost:9200
151+
```
152+
153+
- Values from this file would be automatically used by many `npm` commands.
154+
- ⚠️ Never commit this file or its copy to the repository!
155+
156+
3. 🚢 Start docker-compose with services which are required to start Topcoder Submissions API locally
157+
158+
```bash
159+
npm run services:up
160+
```
161+
- `npm run services:down` can be used to shutdown the docker services
162+
- `npm run services:logs` can be used to view the logs from the docker services
163+
164+
4. ♻ Create tables.
165+
166+
```bash
167+
npm run create-tables
168+
```
169+
5. ♻ Create ES index.
170+
171+
```bash
172+
npm run create-index
173+
```
174+
175+
6. ♻ Init DB, ES
176+
177+
```bash
178+
npm run local:init
179+
```
180+
181+
This command will do 2 things:
182+
- Import the data to the database and index it to ElasticSearch
183+
- Note, to migrate the existing data from DynamoDB to ES, run the following script
184+
```
185+
npm run db-to-es
186+
```
187+
188+
7. 🚀 Start Topcoder Submissions API
189+
190+
```bash
191+
npm run start
192+
```
193+
The Topcoder Submissions API will be served on `http://localhost:3000`
194+
195+
118196
#### Linting JS files
119197

120198
```

config/default.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* Default configuration file
33
*/
4-
4+
require('dotenv').config()
55
module.exports = {
66
DISABLE_LOGGING: process.env.DISABLE_LOGGING || false, // If true, logging will be disabled
77
LOG_LEVEL: process.env.LOG_LEVEL || 'debug',

local/docker-compose.yml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
version: '3'
2+
services:
3+
esearch:
4+
image: "docker.elastic.co/elasticsearch/elasticsearch:6.8.0"
5+
ports:
6+
- "9200:9200"
7+
environment:
8+
- "discovery.type=single-node"

package.json

+6-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@
1919
"test": "mocha test/unit/*.test.js --require test/unit/prepare.js --exit",
2020
"e2e": "mocha test/e2e/*.test.js --require test/e2e/prepare.js --exit",
2121
"cov": "nyc --reporter=html --reporter=text mocha test/unit/*.test.js --require test/unit/prepare.js --exit",
22-
"cov-e2e": "nyc --reporter=html --reporter=text mocha test/e2e/*.test.js --require test/e2e/prepare.js --exit"
22+
"cov-e2e": "nyc --reporter=html --reporter=text mocha test/e2e/*.test.js --require test/e2e/prepare.js --exit",
23+
"services:up": "docker-compose -f ./local/docker-compose.yml up -d",
24+
"services:down": "docker-compose -f ./local/docker-compose.yml down",
25+
"services:logs": "docker-compose -f ./local/docker-compose.yml logs",
26+
"local:init": "npm run init-db && npm run init-es"
2327
},
2428
"dependencies": {
2529
"amazon-s3-uri": "0.0.3",
@@ -30,6 +34,7 @@
3034
"common-errors": "^1.0.4",
3135
"config": "^1.26.2",
3236
"cors": "^2.8.4",
37+
"dotenv": "^8.2.0",
3338
"elasticsearch": "^15.1.1",
3439
"express": "^4.15.4",
3540
"express-fileupload": "^0.4.0",

0 commit comments

Comments
 (0)