This monorepo uses npm workspaces and turborepo
Prod: console.pagoda.co
Dev: core.dev.console.pagoda.co
Copy the following files as starting points, and complete them by obtaining secrets from fellow developers.
frontend/.env.local.example
→frontend/.env.local
backend/.env.nest.local.example
→backend/.env.nest.local
The recommend way to run this project is with VS Code and Dev Containers.
The Visual Studio Code Remote - Containers extension lets you use a Docker container as a full-featured development environment. It allows you to open any folder inside (or mounted into) a container and take advantage of Visual Studio Code's full feature set.
This will create a set of Docker containers with all required dependencies preconfigured by the Console team.
- Follow the official Installation instructions from VS Code to install Docker and the required extensions
- Open this directory in VS Code
- If prompted in the bottom right with the pictured message, click "Reopen in Container".
Otherwise, open the VS Code command palette and runRemote-Containers: Reopen in Container
. - Wait for the build process to complete. You will now have two connected Docker containers running. One is your Node+Typescript development environment and one is a Postgres instance. Your files are mounted into the Node+Typescript container, so edits made through VS Code apply to the files on your local filesystem
- Open an in-editor terminal by selecting
Terminal > New Terminal
from the Menu Bar - Run
npm install
to install dependencies - Run
npm -w database run migrate:reset
to initialize the database - Choose
Run > Start Debugging
or hit F5 to run both the frontend and backend live-reload mode - The frontend is available at
localhost:3000
and the backend is available atlocalhost:3001
. VS Code will automatically expose the port from the Dev Container to the rest of your machine
If you're running in to performance issues running/building the app inside the Dev Container, another option is run the app locally via nvm and Postgres directly through Docker
For now, you will need to make a change to your /etc/hosts
file to properly resolve connections to the database container.
See the following comment: #18 (comment)
You can run a Postgres container with the appropriate default environment variables via either docker compose
or docker run
cd .devcontainer
docker compose up db
docker run -d --name console-db -p 5432:5432 -e POSTGRES_USER=pguser -e POSTGRES_PASSWORD=pgpass -e POSTGRES_DB=devconsole postgres:13-alpine
- Install
nvm
. - Open your preferred terminal and navigate to the project's root directory.
- Run
nvm use
. This will install and activate the correct version ofnpm
andnode
within your terminal session. - Run
npm install
to install dependecies. - Run
npm run dev
to start both the frontend and backend in live-reload mode - The frontend is available at
localhost:3000
and the backend is available atlocalhost:3001
.
The default resource allocations for Docker are relatively low. If you plan to continue using VS Code Dev Containers, it is recommended to raise them significantly in Docker Desktop's preferences so that your development environment can benefit from the full power of your machine.
The node_modules
dir is mounted to a volume instead of the host for increased performance. Running rm -rf node_modules
may interrupt the mount, so opt for the following to wipe dependencies (context)
rm -rf node_modules/* node_modules/.*
Run npm install
from the root to install depenedencies for all packages
Note: for debugging the frontend, add the following line
breakpoint;
These breakpoints will take effect if browser devtools are open.
A debugging configuration is included at .vscode/launch.json
. Choose Run > Start Debugging (F5) to run both the frontend and backend, with breakpoint gutter support for the backend.
To run both the frontend and backend:
npm run dev
To compile and run the project:
npm start