Angular 5为AWS EC2创建应用程序源捆绑包 [英] Angular 5 Create an Application Source Bundle for AWS EC2

查看:68
本文介绍了Angular 5为AWS EC2创建应用程序源捆绑包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在AWS Elastic Beanstalk中,存在用于部署node.js应用程序的向导流。当我进入上传自己的应用程序源代码的步骤时,它概括地描述了它们的3个要求:zip文件,少于500MG,没有父文件夹。
但是他们停在那里。没有细节。
我退学了bash并运行...

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 their 3 requirements: zip file, less that 500MG, no parent folder. But they stop there. No specifics. I dropped out to bash and ran...


ng build --prod

ng build --prod

...,现在有一个dist文件夹。那么...我该在zip文件中包括什么内容以及在哪个文件夹级别?我尝试过/ dist,也尝试过/ myapp / dist,其中包括/ myapp中的所有其他松散文件,但没有其他子文件夹,如/ src。我在网上浏览了所有内容,但是看不到应该是一个有关压缩适用于AWS EC2的应用程序源捆绑包的相当简单的教程。

...and now have a dist folder. So... what do I include in my zip file and at what folder level? I have tried just /dist, and also /myapp/dist which included all the other loose files in /myapp but no other sub folders such as /src. I have looked all over the web, but don't see what should be a fairly simple tutorial on zipping up an Application Source Bundle for AWS EC2.

应包含的内容

推荐答案

我上面问题中的主要罪魁祸首是试图通过以下方式在AWS中运行Angular 5应用程序:使用他们选择的node.js作为我的服务器平台。这是我学到的(在 Albert Haff 等人的帮助下:Angular 5使用Node(ngserve)来在编写代码时模拟网络服务器,但是,即使--prod有受支持的标志,也不用在生产中!部署Angular 5应用程序时,很容易(很诱人)选择node.js作为环境通过Beanstalk-但不要这样做!

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. 从Angular 5项目文件夹中,运行ng build --prod(并考虑如果可以的话,添加--aot)

  2. 如果可以的话,可以在构建刚刚创建(或更新)的新/ dist文件夹中,为我在中运行压缩dist / *;执行brotli $ i;完成

  3. ,从/ dist文件夹中压缩所有内容,包括子文件夹。

  4. 转到beantalk,然后在创建Web服务器环境时,选择Tomcat(或其他任何普通的旧Web服务器,但是不要选择node.js,即使它位于列表!)。

  5. 在应用程序代码上,选择上传自己的文件,然后浏览到在上面的第3步中创建的.zip文件。

  6. 单击创建环境,几分钟后您的Angular 5应用将可以在互联网上运行。

  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.

现在,从这里开始需要连接您的域名。为此,请使用Route 53。

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

这篇关于Angular 5为AWS EC2创建应用程序源捆绑包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆