-
Notifications
You must be signed in to change notification settings - Fork 8
Dev Workflow
To use the new Docker workflow, make sure to have Visual Studio Code and Docker Desktop installed. (MongoDB Compass is additionally recommended but not required.)
Special note: If you only have 8GB of RAM (as opposed to 16 or more), it's recommended that you specifically instruct WSL (Windows Subsystem for Linux) to use fixed amounts of memory - see the ** note at the bottom of this page.
Next:
- Start VS Code and run Dev Containers: Clone Repository in Named Container Volume... from the Command Palette (F1). [name it Scoutradioz]
- And then enter the repo url
- It'll take a while for the container to set up. Once it's ready, open a new terminal window (Ctrl + `) and then run
yarn dev
. It may take a while to get started, but the website should launch and be accessible at http://localhost:3000.
As part of the docker setup process, a trimmed-down snapshot of the Scoutradioz database will be imported into a new volume on your local machine.
This snapshot has data originally recorded from The Gearheads, but with all personal information removed and randomized usernames.
The default org password is password
. All users except for 00 Dev Account are set to the Scouter permission level. Log in to 00 Dev Account and choose a password, and then that account will have Global Admin permission levels.
The one major feature missing in the database snapshot is an API key for The Blue Alliance, so you will not be able to fetch data from TBA until you do the following:
- Create a TBA account: https://www.thebluealliance.com/account
- After signing in, navigate to Read API Keys. Create a new key and then copy the key (should look something like
Eejoa6qcahNOAhgMyMtkbU5cNt4bvPmt2r5XAl2a8f0XNdmNbYsLnosZnlOQijST
) - Add the TBA Auth key to the database by doing the following:
-
While the database is running, connect to mongodb://localhost:27017 and navigate to the
app
database. -
Click on the + button to create a collection. Name it
passwords
. -
Next, click Add Data -> Insert document.
-
Delete the existing
{ _id }
junk and paste this in, but inserting the TBA key you copied earlier:
{ "name": "tba-api-headers", "headers": { "accept": "application/json", "X-TBA-Auth-Key": "(PASTE IN YOUR KEY HERE)" } }
- And lastly, press Insert. (MongoDB will still automatically create a new
_id
field for that entry anyways.)
-
Check *Info on the developer script at the bottom for more info on what happens behind the scenes with yarn dev
.
- Open Visual Studio Code
- If ScoringApp-Serverless is not already open: File > Open Folder or Ctrl + K, Ctrl + O; then open the folder containing this repository
-
Ctrl + ` to open terminal
- Make sure either PowerShell or cmd is selected in the dropdown
-
If this is the first time setting up, enter
yarn setup
(in the background, it runsyarn install
in the project root and all 3 main Express functions) -
If this is NOT the first time setting up, Enter
yarn update
to update the internal packages linked within this repository (scoutradioz-utilities
, etc.) - Enter
yarn dev
to run the developer script*.
- To edit files, browse in the Explorer tab (Ctrl + Shift + E) and open by left-clicking once.
- Make sure
mongod
is running - In Compass, connect to
mongodb://127.0.0.1:27017/
- In Compass, drop the
app
database - Open PowerShell or bash in some temporary folder that is NOT connected to an automatic cloud backup service
- Enter
mongodump --uri "{Full connection string to prod database}" --db prod
- Enter
mongorestore ./dump/prod --db app
- Close cmd or PowerShell
- Open PowerShell or bash in some temporary folder that is NOT connected to an automatic cloud backup service
- Delete
./dump/prod
and./dump/qa
/./dump/test
if they exist - Back up QA or Test:
mongodump --uri "{Full connection string to qa or test database}"
- Download prod:
mongodump --uri "{Full connection string to prod database}"
- Connect to the remote database cluster in Compass
- Drop the QA or Test database
- Back in PowerShell or bash, enter
mongorestore --uri "{Full connection string to QA or Test database}" --db {qa or test} ./dump/prod
to upload the contents of./dump/prod
(the prod database download) to the QA or Test database
- It will run all necessary scripts and commands inside child threads:
- MongoDB
- Compilation of static TS->JS files, in watch mode
- Compilation of static LESS->CSS files, in watch mode
- The two main Express functions (Primary and Upload)
- If you get an MongoDB error: Check C:\data\db. If it does not exist, create it.
- If you wish to change where your database is located, set an environment variable
MONGODB_PATH
to specify where the database should be opened.
- If you wish to change where your database is located, set an environment variable
- To restart Primary and Upload, simply type
rs
into the console and press enter.
- Open File Explorer and navigate to
C:\Users\{yourWindowsUsername}
- Create a file called .wslconfig (NB, it must start with a period '.' character!)
- In this file put the following contents:
[wsl2]
memory=5GB
processors=4
swap=6GB
(tune as needed)