Github - Deploying a Nest.js App to AWS Elastic Beanstalk (Node.js Platform) with Github Actions
Steps
Push code to GitHub
Trigger GitHub Actions to
install dependenciesandbuild projectDeploy the project to AWS Elastic Beanstalk
Run script in Procfile
(npm run start:prod)
What do we need?
Procfile - Add
Procfileto your Nest.js Application.ebignore - Add
.ebignoreto your Nest.js ApplicationPORT - Let your Nest.js Application listening port match to Elastic Beanstalk proxy forwarding port
GitHub Workflow files
Add Procfile to the root of your Nest.js Application
Procfile to the root of your Nest.js Applicationweb:npm run start:prodAdd .ebignore to the root of your Nest.js Application
.ebignore to the root of your Nest.js Application/node_modulesIf.ebignoreis present, the EB CLI doesn't read.gitignore.
This file prevents dist folder to be ignored when deploy.
Set Environment Variable PORT to 8080 at Elastic Beanstalk - Config
PORT to 8080 at Elastic Beanstalk - ConfigIf your application listening to process.env.PORT, then you can set Elastic Beanstalk Config PORT to any port. Otherwise, set your application listening port to 8080 to match the default proxy forwarding port.

GitHub Workflow files
Last updated
Was this helpful?