isomerpages / isomercms-backend

A static website builder and host for the Singapore Government
5 stars 1 forks source link

Running dev environment

  1. grab a copy of the environment variables from the 1PW Isomer vault
  2. ensure that you have your AWS_ACCESS_KEY_ID together with AWS_SECRET_ACCESS_KEY. These can be generated from the IAM console, under security credentials. (see here for more details)
  3. next, generate your ssh keys and add them to the .env file. (See here for details on generating a new SSH key and adding it to your Github account.)
  4. run npm run dev

Setup

  1. Ensure pre-commit hooks are setup for safe commits. See below section on "Setting up Git Guardian"
  2. Ensure node 14 is installed. Install and use nvm to manage multiple node versions.
  3. Run npm i to install required packages
  4. Ensure Docker is installed
  5. Run npm run dev:services to bring up the docker containers
  6. Run npm run dev to start the server

Setting Up Git Guardian

  1. Install GitGuardian
brew install gitguardian/tap/ggshield
  1. Add the API Key to your .env file
# Service API key from GitGuardian account
export GITGUARDIAN_API_KEY=abc123

Notes:

Only if necessary,

E2E Tests

To run the E2E tests successfully, you will need to define the following environment variables:

export E2E_TEST_REPO="e2e-test-repo"
export E2E_TEST_SECRET="blahblahblah" // this should match the value of CYPRESS_COOKIE_VALUE on
// the frontend
export E2E_TEST_GH_TOKEN="" // this can be your own personal GH access token, or  the token from our
// specialized E2E test user

Release

Run the following on the release branch to tag and push changes automatically:

npm run release --isomer_update=<versionType>

where versionType corresponds to npm version types. This only works on non-Windows platforms, for Windows, modify the release script to use %npm_config_update% instead of $npm_config_update.

Running migrations on a remote database in a private subnet of a VPC

The following steps are needed before you can run migrations on a remote database in a private subnet of an AWS VPC.

First, ensure that you are connected to AWS VPN as only the VPN is whitelisted to use the EC2 instance1.

Next, you will require the correct environment variables and credentials.

Next, run the following command: npm run jump:<staging | production>. This sets up the port-forwarding service. Finally, run the following command in a separate terminal: npm run db:migrate:<staging | production> to run the migration.

What happens under the hood is described below: You need to set up a local port-forwarding service that forwards traffic from a specific local port, e.g. 5433, to the database via the bastion host (remember: the bastion host resides in the public subnet of the VPC and thus can be contactable from your computer).

Finally, we want to run the migration script.


1 To check whitelisted IPs in EC2 instance,