Skip to content

malcolmredheron/gambit

Repository files navigation

Installation

Basic packages

Install the nix package manager from from https://nix.dev/install-nix and then use nix-shell . to get the packages declared by default.nix.

npm and npx should now be available in the shell environment.

Development

After cloning or updating, and before committing:

  • dev/precommit.sh

To run all tests on the command line (and rerun when files change):

  • npm test

To run all tests in the browser:

  • npm run testInBrowser
  • Open a browser to https://localhost:1234/

To run the app:

  • docker-compose up --build
    • This builds all of the docker images and runs them.
    • If the database is not populated, populateDb will populate it with sample data.
  • Open a browser to https://localhost/
    • To hit the dev server, which reloads as the code is changed (your source tree is mounted into the container), run this in the js console in the browser: document.cookie = "code=dev".

The database will survive stopping and starting the cluster. To wipe the persistent state of the app:

  • docker-compose down

To run admin scripts against the cluster:

  • Eg: src/server/admin/admin.sh src/server/admin/DumpUser.ts --email=alice@example.com
  • We run admin scripts through docker so that they run in the same context of environment, secrets, etc as the servers, regardless of whether we are running them in production or development

Upgrading

Upgrade nix packages: Follow the instructions in default.nix

Upgrade npm packages:

  • npx npm-check-updates to check for updates
  • npx npm-check-updates -u to take all updates

Debugging

  • Traefik dashboard: http://localhost:8080/dashboard/#/
  • Connect to postgres: docker exec -it gambit_db_1 psql -h localhost -U postgres -d gambit

Intelij

Settings

  • Editor
    • Inspections
      • Javascript and Typescript
        • Async code and promises: enable all and set to error (we don't know how make eslint check for forgetting to await a promise)

Parcel

Parcel's default babel config is generated by https://github.com/parcel-bundler/parcel/blob/40f24178138445abe8746c0dec996b0cda1bfe4b/packages/transformers/babel/src/config.js#L160

Production

  • mkdir -p data/server/traefik
  • touch data/server/traefik/acme.json
  • Go to https://sentry.io/settings/account/api/auth-tokens/, make a token with the project:releases scope, and paste the token into .sentry-upload-token
  • docker-compose --env-file=.prod.env up --build