My node.js app consists of two things, an express backend and a react frontend.
I have two package.json files in this structure
package.json
/app/package.json
What I want to do is run a script in my frontend folder, app, that builds my code.
the script I want to run is npm install
and npm run build
How do I run this script after a deploy have happened?
commands:
01_app_npm_install:
command: npm install
cwd: app/
02_app_npm_build:
command: npm run build
cwd: app/
But it returns an error saying that "No such file or direc tory: 'app/'."
Is this possible to do on aws elastic beanstalk?
Update: This is now much more developed and defined.
https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/platforms-linux-extend.html
Original:
I haven't done nodejs myself with Elastic Beanstalk, but I have done a lot of Django.
The commands:
section runs before the project files are put in place. This is where you can install server packages for example.
The container_commands:
section runs in a staging directory before the files are put in its final destination (which is /var/app/current it seems for nodejs). Here you can modify your files if you need to.
Reference for above: http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html
You can also run a post deploy scripts. This is not very well documented (at least it wasn't). You can do something like this:
files:
"/opt/elasticbeanstalk/hooks/appdeploy/post/99_restart_delayed_job.sh":
mode: "000755"
owner: root
group: root
content: |
#!/usr/bin/env bash
service httpd restart
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With