Node.js and pnpm must be installed. This project uses pnpm's workspace feature for the monorepo structure.
pnpm install
in the project directory.db.sqlite
file in ./var
, create it by running pnpm db:push
..env
file with the required environmental variables. This file is gitignored for security reasons. You can either obtain it securely from someone who has it on his or her machine or create a new one by copying ./.env.blueprint
and renaming it to .env
.pnpm dev
to start the development server. It will watch for file changes and rebuild the app. Note that this is only a development server and may lack some production functionality..pem
key file in the project root and rename it to ssh-key.pem
(this file is gitignored).pnpm ssh:connect
on a UNIX machine to connect to the server.curl -fsSL https://get.pnpm.io/install.sh | sh -
.pnpm install pm2 -g
.This setup would already allow you to upload code via SSH, perform the steps form the local section above via SSH, and run the server using pm2. To automate this, see below how to set up continuous integration.
SSH_PRIVATE_KEY
..github/workflows/deploy-ec2.yaml
, which will build and transfer the app to EC2.echo "[paste env content here] > .env".
.NODE_ENV=production pm2 start ~/codex-insurance-fullstack/process.json
. Use pm2 status
to check status, and pm2 logs
to see logs.The Node server runs on port 3000 by default. To serve on the standard HTTP port 80, running the Node server as a superuser is required. However, this is considered a security risk. A more secure approach is to use a reverse proxy.
To securely serve the Node app on port 80, you need to install Nginx on the server. Nginx will listen on port 80 and forward all requests to your Node app running on port 3000. Follow this tutorial for detailed instructions: How to run a Node.js server with Nginx.
If the sites-available
and sites-enabled
folders do not exist, create them. If the Nginx restart command doesn't work, try the following commands:
sudo pkill -f nginx & wait $!
sudo systemctl start nginx
.env
file accordingly.pnpm db:studio
. The link to the studio will appear in the command prompt.