|
1 |
| -# CodeStream Backend Services |
2 |
| - |
3 |
| -On the backend (aka. the server-side), CodeStream runs a number of services to |
4 |
| -provide all the functionality needed for the clients. The default development |
5 |
| -environment will use the codestream broadcaster with outbound mail |
6 |
| -disabled. |
7 |
| - |
8 |
| -## Development Setup with docker-compose |
9 |
| - |
10 |
| -### Prerequisites |
11 |
| - |
12 |
| -1. Mac or Linux computer using zsh or bash. |
13 |
| - |
14 |
| -1. [Docker Desktop](https://www.docker.com/products/docker-desktop) which we'll |
15 |
| - use to provide MongoDB. |
16 |
| - |
17 |
| -1. Make sure you are authenticated with vault!, i.e. |
18 |
| - |
19 |
| - `newrelic-vault us login -method=okta username=<username> totp=<otp>` |
20 |
| - |
21 |
| -1. If you plan to enable outbound email, make sure you have a working |
22 |
| - AWS session to the CodeStream development account. If this requires |
23 |
| - use of the `AWS_*` environment variables and you plan to launch from |
24 |
| - the debugger, ensure they're defined in the appropriate block in |
25 |
| - `.vscode/launch.json`. |
26 |
| - |
27 |
| -### Installation |
28 |
| - |
29 |
| -For local development we use docker compose to only run mongodb. You will need to run the |
30 |
| -api-server locally via your IDE or command line. |
31 |
| - |
32 |
| -1. Clone and setup |
33 |
| - [faker-service-gateway](https://source.datanerd.us/codestream/faker-service-gateway). |
34 |
| - Faker service gateway will handle SSL and proxy requests to the api-server. |
35 |
| - |
36 |
| -1. Clone the [codestream-server](https://github.com/teamcodestream/codestream-server) repo. |
37 |
| - |
38 |
| -1. Start up the docker container for MongoDB via docker compose. |
39 |
| - ``` |
40 |
| - docker compose up mongodb -d |
41 |
| - ``` |
42 |
| -1. Install dependencies |
43 |
| - ``` |
44 |
| - npm run install:all |
45 |
| - ``` |
46 |
| - |
47 |
| -### Mongo upgrade caveat |
48 |
| - |
49 |
| -If you have been running mongodb 4 in docker compose you will need to delete the mongodb volume to get a clean start |
50 |
| -for mongodb 5, otherwise mongo will exit shortly after startup. This will delete all the data in your local docker |
51 |
| -mongodb instance. |
52 |
| - |
53 |
| -``` |
54 |
| -docker compose down --volumes |
55 |
| -docker compose up mongodb -d |
56 |
| -``` |
57 |
| - |
58 |
| -With a fresh database you will need to run `./start-api-server.sh -init-db-only` before being able to run api-server from the IDE. |
59 |
| - |
60 |
| - |
61 |
| -### Method 1 - launch from shell and run natively |
62 |
| - |
63 |
| -1. Setup and start up the api-server without docker. The default |
64 |
| - behavior is to initialize the database and disable outbound |
65 |
| - email queueing. |
66 |
| - ``` |
67 |
| - ./start-api-server.sh [-init-db-only | -no-db | -enable-mailout | -mock-mode ] |
68 |
| - ``` |
69 |
| - |
70 |
| -### Method 2 - launch from IDE |
71 |
| - |
72 |
| -1. Review the pre-reqs above to ensure you set any additional vars |
73 |
| - needed for your use case. `.vscode/launch.json` has some comments |
74 |
| - to help. |
75 |
| - |
76 |
| -1. Select any of the the `api_srv.js` run configurations from vscode or |
77 |
| - jetbrains. |
78 |
| - |
79 |
| -Point your CodeStream extension to https://localhost.newrelic.com:12079. You |
80 |
| -should be able to login and see o11y. |
81 |
| - |
82 |
| -Develop to your heart's content!!!! We _love_ pull-requests. |
83 |
| - |
84 |
| -## Run everything in docker |
85 |
| - |
86 |
| -Not working right now :(. Check back later. |
87 |
| - |
88 |
| -## Running Tests |
89 |
| - |
90 |
| -As usual, make sure you are authenticated with vault. |
91 |
| - |
92 |
| -Start the api server - use `-mock-mode` flag if needed |
93 |
| -```bash |
94 |
| -./start-api-server.sh [-init-db-only | -no-db | -enable-mailout | -mock-mode ] |
95 |
| -``` |
96 |
| - |
97 |
| -In a separate terminal, source testMode.sh (this will also set CS_API_MOCK_MODE=1) |
98 |
| - |
99 |
| -```bash |
100 |
| -. ./testMode.sh |
101 |
| -``` |
102 |
| - |
103 |
| -then run the tests |
104 |
| -```bash |
105 |
| -cd api_server |
106 |
| -npm run test |
107 |
| -``` |
| 1 | +NOTE: This code will be archived by the end of July 2024. |
0 commit comments