Angular 5 Create an Application Source Bundle for AWS EC2

后端 未结 1 639
闹比i
闹比i 2021-01-23 04:45

In AWS Elastic Beanstalk, there is a wizard flow for deploying node.js apps. When I get to the step for \"upload your own\" application source, it describes in generic terms the

相关标签:
1条回答
  • 2021-01-23 05:35

    The cardinal sin in my question above was attempting to run my Angular 5 app in AWS by using their choice for node.js as my server platform. Here is what I learned (with some help from folks like Albert Haff: Angular 5 uses Node (ng serve) to simulate a webserver while you code. However, even though there is a supported flag for --prod, it's not to be used in production! It's really easy (and tempting) to select node.js as the environment when deploying your Angular 5 app via Beanstalk -- but don't do it!

    1. from within your Angular 5 project folder, run ng build --prod ( and consider adding --aot)
    2. if you can, from within the new /dist folder that the build just created (or updated), optionally run compression like for i in dist/*; do brotli $i; done
    3. from within the /dist folder, zip up ALL the contents including subfolders.
    4. go to beanstalk, and as you create a webserver environment, select Tomcat (or any other plain old webserver, but DON'T pick node.js even though it's on the list!).
    5. on Application Code, select to Upload Your Own, and browse to the .zip file you created in step 3 above.
    6. click Create Environment and in a few minutes your Angular 5 app will be serving up on the internet.

    Now, from here you will likely need to connect up your domain name. Use Route 53 for that.

    0 讨论(0)
提交回复
热议问题