- Install Docker
- Install
direnv
- Loads env vars from
.env
, which is convenient
- Loads env vars from
- Install
cockroachdb
- Create an env file:
cp .env.example .env
- Set the uncommented env var values
docker volume create productcatalog_node_modules
docker-compose up --build
- To set up or restore your local database using the production DB, run
./scripts/set_local_db_to_prod.sh [DUMP FILENAME]
- The dump filename is an optional arg that will use a local
*.sql
or*.dump
file. Without the dump filename, a backup of the production database will be created, and your local instance will be restored with that backup. - WARNING: This will erase any data you currently have on your local DB.
- The dump filename is an optional arg that will use a local
docker-compose start
- Open the browser to
localhost:3000
- Navigate to
localhost:3333/graphql
- To make make authorized requests to the GraphQL API, you have to add
{"Authorization": "supersecretspicysauce"}
to the HTTP Headers section in the bottom left corner of the page.
We host the app on Heroku.
We deploy automatically to Heroku with every merged PR that passes CI via a GitHub integration. If you want to deploy manually do the following:
- While on
main
, rungit push heroku main:master
- Run all integration tests:
./scripts/integration_tests.sh
- Do not use
yarn run test:integration
, because all integration tests require a test DB, and the bash script takes care of setup and teardown.
- Do not use
- Run all unit tests:
docker-compose run --rm app yarn run test:unit
- To get code editor linters and other functionality working correctly, you have to install linting/testing/type packages locally as well as on your Docker container. This mostly works, but sometimes creates weird conflicts that require a reset per below.
- Sometimes you'll install packages, then get errors that say your new package is missing 😑. The only thing that seems to fix it is to remove the
node_modules
volume and rebuild the image:docker container rm <container name>
docker volume rm <node_modules volume name>
docker volume create <node_modules volume name>
docker-compose build --no-cache
- After installing NPM packages, run
npx prisma generate
. - Only run
docker-compose start db
. The NextJS app doesn't depend on the other services, andclient
would conflict with the app's use of port 3000. - Run
npm run dev
to start the app.