First, install Yarn (modern npm replacement).
Then, install NodeJs (currently the LTS version we are using is 20.11.1).
The .env file is needed for development and locally running the stack.
It must be added to the root directory of the project and match the .env.template
To build it once:
yarn run build
To constantly build it when something changes, run:
yarn watch
yarn start
Runs the production build on several local web instances behind nginx, like staging runs several dynos behind Heroku's router. Install nginx and the Heroku CLI first:
brew install nginx
brew install heroku/brew/herokuThen:
yarn run:heroku:localThis builds the app, starts nginx (yarn nginx:start) and then the web instances
(yarn run:heroku:start). The app is served at http://localhost:9000.
Ctrl-C stops the web instances but nginx keeps running: stop it with yarn nginx:stop, or leave it
running and restart only the instances with yarn run:heroku:start (starting nginx twice fails with
"address already in use").
The instance ports (9001, 9002, ...) follow PORT in the .env file, and
nginx.conf routes to 4 instances: to run more, change web=4 in the run:heroku:start script,
add the ports to nginx.conf, and keep instances x PG_MAX_CONNECTIONS (20 by default) under
postgres max_connections (100 by default).
Create a new Postgres local instance via Docker. Run the command:
sudo docker run -d --name fra-db -p 5442:5432 -e POSTGRES_DB=frap-dev -e POSTGRES_PASSWORD=frap -e POSTGRES_USER=frap postgres:18.6Otherwise, check .env configurations for setting it up manually (note that the server port is not default!)
Install 2 instances of redis 6.2.6 (one for queues and one for data)
sudo docker run --name fra-queue-redis -p 6379:6379 -d redis:6.2.6sudo docker run --name fra-data-redis -p 6389:6379 -d redis:6.2.6Migrations are run automatically on startup of the server.
When you need e.g. a new table to the database (say "kuikka"), create a migration template with:
yarn migration-step:create kuikkaNow you'll see new sql files in src/tools/migrations/steps/steps/.
You should edit the <timestamp-kuikka-up.ts to contain your create table -statement.
Make sure migrations can be ran twice without side effects.
ts-node src/tools/db/export.ts(cd src/tools/db && tar -czf fixtures.tar.gz fixtures && gpg --batch --yes --passphrase "$BACKUP_PASSPHRASE" --symmetric --cipher-algo AES256 -o fixtures.tar.gz.gpg fixtures.tar.gz && rm fixtures.tar.gz)