【问题标题】:Using npm db-migrate with Elastic Beanstalk将 npm db-migrate 与 Elastic Beanstalk 一起使用
【发布时间】:2020-05-06 17:30:44
【问题描述】:

我正在尝试自动化使用 npm db-migrate 的 nodejs 应用程序的 Elastic Beanstalk 部署。我已经阅读了Customizing Software on Linux Servers 的 AWS 文档,看来我应该使用容器命令。我创建了一个文件 10_db_migrate.config 并包含了这个命令:

container_commands:
  dbmigrate:
    command: "./node_modules/db-migrate/bin/db-migrate up -e production"
    leader_only: true

我尝试了多种路径组合,包括 /tmp/deployment/application/node_modules/... 但它们都返回以下错误:

INFO [2903] - [应用程序更新代码-管道-1579538046076-21b269f7103572f7a9d500d4158751de32e395c4@20/AppDeployStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild/postbuild_0_MyAppAPI/Command dbmigrate]:活动执行失败,因为:/usr/bin/无此文件或目录 (ElasticBeanstalk::ExternalInvocationError)

我错过了什么?

【问题讨论】:

    标签: amazon-web-services amazon-elastic-beanstalk dbmigrate


    【解决方案1】:

    我让它工作了。部分问题是我试图让它比我需要的更困难。我真正需要做的是来自这个post。下面是我最终的 container_command:

    container_commands:
      00_node_binary:
        command: "ln -sf `ls -td /opt/elasticbeanstalk/node-install/node-* | head -1`/bin/node /bin/node"
      10_npm_binary:
        command: "ln -sf `ls -td /opt/elasticbeanstalk/node-install/node-* | head -1`/bin/npm /bin/npm"  
      20_dbmigrate:
        command: "./node_modules/.bin/db-migrate up"
        leader_only: true
    

    我不久前发现了这一点,但我认为我还需要访问环境变量来做我想做的事。经过一些额外的测试后,我能够确定我不需要访问环境变量,所以这可以满足我的需要。仍然想知道如何引用环境变量以在 Elastic Beanstalk 上的 db-migrate 中创建准备好的语句,但现在有更紧迫的需求。

    【讨论】:

      猜你喜欢
      • 2017-08-08
      • 1970-01-01
      • 2022-12-13
      • 2016-10-05
      • 2020-07-17
      • 2016-05-12
      • 2020-08-18
      • 2017-08-03
      • 2015-02-23
      相关资源
      最近更新 更多