【问题标题】:Deploying Ember.js app to AWS Elastic Beanstalk将 Ember.js 应用程序部署到 AWS Elastic Beanstalk
【发布时间】:2021-02-11 16:28:23
【问题描述】:

我已经尝试并搜索如何在 AWS Elastic Beanstalk 上部署 emberjs 应用程序,但我找不到方法。 我正在使用 EB CLI 进行部署和配置。

如果有人有将 ember 应用程序部署到 Elastic Beanstalk 的经验,请分享。

【问题讨论】:

  • 您能否详细说明您为什么要使用 Elastic Beanstalk?你在用Ember Fastboot吗?否则,Ember 部署只是托管在某处的一堆静态文件。该场景在 AWS 上的常见部署使用 S3 和 CloudFront。 Ember-cli-deploy 覆盖它in its documentation
  • 嗨@jelhan,你是对的。我是 ember 和 AWS 的新手,所以不知道工作环境。不,我没有使用 Ember Fastboot。
  • 在这种情况下,我建议改用 S3 和 CloudFront。将保护您的复杂性和金钱。 ;-)

标签: amazon-web-services ember.js amazon-elastic-beanstalk


【解决方案1】:

正如@jelhan 在线程评论部分中提到的,您不需要 ElasticBeanstalk 来托管静态文件。如果您不使用 ember-fastboot,则只需使用 S3 和 CloudFront。

您也可以使用 AWS 放大 https://aws.amazon.com/amplify/console/

除此之外,要将您的应用程序安装到 Elastic Beanstalk 上,请使用以下步骤:

  1. .ember-cli.js 文件中更新/添加到"dist/www" 的dist 路径:
      "outputPath": "dist/www"
  1. 添加package.json
   {
      "name": "ember_frontend_server",
      "version": "1.0.0",
      "description": "We are using node server to serve static files",
      "main": "server.js",
      "scripts": {
        "start": "node server.js"
      },
      "author": "",
      "license": "MIT",
      "dependencies": {
        "express": "^4.17.1",
        "path": "^0.12.7"
      }
    }
  1. 添加一个server.js 文件来托管静态文件
var express = require('express');
var path = require('path')

var app = express();

var port = process.env.PORT || process.argv[2] || 8081;

app.use(express.static(path.normalize(__dirname + '/www')))

app.use('*', (req, res) =>
{
  res.sendFile(__dirname +'/www/index.html');
});

app.listen(port);
  1. 通过 eb init 初始化弹性 beanstalk 设置
  2. 通过运行 eb deploy 命令将应用部署到 elastic beanstalk

【讨论】:

    猜你喜欢
    • 2018-12-07
    • 2022-06-11
    • 2018-04-21
    • 2017-04-14
    • 2016-09-05
    • 2015-07-17
    • 2020-07-05
    • 2013-03-18
    • 2013-04-03
    相关资源
    最近更新 更多