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

查看:31
本文介绍了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.

上传的 zip 文件中应包含哪些内容?

What should be included in the zip file for upload?

推荐答案

我上面问题中的主要问题是尝试使用他们选择的 node.js 作为我的服务器平台在 AWS 中运行我的 Angular 5 应用程序.这是我学到的东西(在Albert Haff 等人的帮助下:Angular 5 使用 Node (ng serve)在编写代码时模拟网络服务器.然而,即使 --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 文件夹中,可以选择运行压缩,例如 for i in dist/*;做 brotli $i;完成
  3. 从/dist 文件夹中,压缩包括子文件夹在内的所有内容.
  4. 转到 beanstalk,并在创建网络服务器环境时,选择 Tomcat(或任何其他普通的旧网络服务器,但不要选择 node.js,即使它在列表中!).
  5. 在应用程序代码上,选择上传您自己的文件,然后浏览到您在上述第 3 步中创建的 .zip 文件.
  6. 点击创建环境,几分钟后您的 Angular 5 应用就会在互联网上发布.

现在,您可能需要从这里连接您的域名.为此,请使用 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天全站免登陆