Cambridge-Community-Kitchen / cck-volunteer-web-app

https://volunteer.cckitchen.uk
3 stars 2 forks source link

Developer Quickstart

The console commands below assume you are developing on a Debian-based Linux system and were tested with Ubuntu 22.04.1; modify to suit your particular setup.

Install base requirements

To run this code, you will need:

sudo apt -y install curl
curl -sL https://deb.nodesource.com/setup_16.x | sudo bash -
sudo apt update
sudo apt -y install git nodejs mysql-server

Clone the repo and install dependencies

git clone https://github.com/agolden/cck-volunteer-web-app
cd cck-volunteer-web-app
npm install

Browser

We suggest installing and using Chromium as your principal browser for development purposes.

sudo apt install -y chromium-browser

IDE

We suggest installing and using Visual Studio Code as your integrated development environment (IDE).

Development environment setup

Environment variables

To successfully run this application, you must set several environment variables.

The .env.local file must be present in the root of the directory. You can use the example environment variables file as a starting point:

cp example.env.local .env.local
ln -s .env.local .env

In this file, there are several default variables that may be changed (and several others that may be added):

Helper scripts

A series of (optional) scripts are provided that will simplify the process of setting up your local development environment. Execute them in the following sequence:

A script has been provided to randomly generate passwords for your .env.local file:

./scripts/generate-passwords.sh

A script has been provided to update the database's root user's password from the .env.local file:

sudo ./scripts/update-master-db-password.sh

A script has been provided to create the application's database and database user:

./scripts/create-db.sh

Application scripts

The package.json defines a number of scripts for use in development:

Run the scripts as follows:

npm run <<script>>

For example:

npm run update-schema

Database management

Stack management

The AWS cloudformation stack can be created / updated / deleted using the AWS CLI, for example:

aws cloudformation create-stack --stack-name my-awesome-stack-name --template-body file://aws/aws-cloudformation.yml --capabilities CAPABILITY_NAMED_IAM
aws cloudformation update-stack --stack-name my-awesome-stack-name --template-body file://aws/aws-cloudformation.yml --capabilities CAPABILITY_NAMED_IAM
aws cloudformation delete-stack --stack-name my-awesome-stack-name

Once the stack has been successfully deployed, the relevant secrets can be retrieved as follows:

aws secretsmanager get-secret-value --secret-id aws-arn:aws:secretsmanager:eu-west-2:myaccountid:secret:my-credential-id

Database backup

Here is an example of backing up the contents of the MySQL server:

mysqldump -h "myawesome.database.instance.com" --all-databases --triggers --routines --events --user=admin -p > dump.sql