[Elastic Beanstalk] React and Node to Elastic Beanstalk

Posted by Jarxi on 2020-09-18

Deploy React and Node project to Elastic Beanstalk

Sources:
AMS Official docs
How to Log
Very good source with sample project
Extra source

Important Points

  1. tail -n 50 /var/log/web.stdout.log prints last 50 lines of node terminal output
  2. tail -n 50 eb-engine.log logs errors before node is started
  3. eb create creates environment
  4. eb init initialize an application. Multiple applications can run in one environment.
  5. .ebignore ignore files when type in eb deploy
1
2
3
4
5
6
if (process.env.NODE_ENV !== 'development') {
app.use(express.static('../my-app/build'));
app.get('*', (req, res) => {
res.sendFile(path.resolve(__dirname, '../my-app', 'build', 'index.html'));
});
}

super important!!! It will run react build folder at nodejs’s port. (8080 or 5000)

Steps

  1. build a react build with npm run build under the react folder (my-app)
  2. eb create
  3. code .ebignore to create ignore file
  4. ignore all the files that mentioned before
  5. eb deploy


支付宝打赏 微信打赏

赞赏一下