在AWS Elastic Beanstalk中提升Sails.js Docker图像时出错

在AWS Elastic Beanstalk中提升Sails.js Docker图像时出错,docker,sails.js,amazon-elastic-beanstalk,Docker,Sails.js,Amazon Elastic Beanstalk,我正在Docker图像中运行AWS Elastic Beanstalk(EB)中的Sails.js应用程序。我的工作流程是在本地构建Docker映像,推送到ECR,然后部署我的AWS配置(例如:Dockerrun.AWS.json和Nginx的其他配置)。我的应用程序是一个测试不同技术集成的POC,所以是的,我现在正在使用MemoryStore,不过我主要遵循 在本地运行我的Docker映像(在生产模式下,通过将节点_ENV设置为生产),容器/应用程序可以正常启动并准备就绪。我构建了一个模拟EB

我正在Docker图像中运行AWS Elastic Beanstalk(EB)中的Sails.js应用程序。我的工作流程是在本地构建Docker映像,推送到ECR,然后部署我的AWS配置(例如:
Dockerrun.AWS.json
和Nginx的其他配置)。我的应用程序是一个测试不同技术集成的POC,所以是的,我现在正在使用MemoryStore,不过我主要遵循

在本地运行我的Docker映像(在生产模式下,通过将
节点_ENV
设置为
生产
),容器/应用程序可以正常启动并准备就绪。我构建了一个模拟EB反向代理的Nginx映像,这样我就可以在本地测试SSL终止、安全cookie等(使用docker compose将所有内容绑定在一起),而且一切都非常好

但是,当我部署到EB时,我的容器/应用程序需要很长时间才能启动。拉着原木,我看到:

debug: Please note: since `sails.config.session.cookie.secure` is set to `true`, the session cookie 
debug: will _only_ be sent over TLS connections (i.e. secure https:// requests).
debug: Requests made via http:// will not include a session cookie!
debug: 
debug: For more help:
debug:  • https://sailsjs.com/config/session#?the-secure-flag
debug:  • https://sailsjs.com/config/session#?do-i-need-an-ssl-certificate
debug:  • https://sailsjs.com/config/sails-config-http#?properties
debug:  • https://sailsjs.com/support
debug: 
Warning: connect.session() MemoryStore is not
designed for a production environment, as it will leak
memory, and will not scale past a single process.
[33mwarn[39m: The default `sails-disk` adapter is not designed for use as a production database.
[33mwarn[39m: Instead, please use another adapter like sails-postgresql or sails-mongo.
[33mwarn[39m: For more info, see: http://sailsjs.com/docs/concepts/deployment
[33mwarn[39m: To hide this warning message, enable `sails.config.orm.skipProductionWarnings`.
[33mwarn[39m:  [?] If you're unsure, see https://sailsjs.com/support
[31merror[39m: Failed to lift app:

... repeats the above ~30 times

debug: Please note: since `sails.config.session.cookie.secure` is set to `true`, the session cookie 
debug: will _only_ be sent over TLS connections (i.e. secure https:// requests).
debug: Requests made via http:// will not include a session cookie!
debug: 
debug: For more help:
debug:  • https://sailsjs.com/config/session#?the-secure-flag
debug:  • https://sailsjs.com/config/session#?do-i-need-an-ssl-certificate
debug:  • https://sailsjs.com/config/sails-config-http#?properties
debug:  • https://sailsjs.com/support
debug: 
Warning: connect.session() MemoryStore is not
designed for a production environment, as it will leak
memory, and will not scale past a single process.
[33mwarn[39m: The default `sails-disk` adapter is not designed for use as a production database.
[33mwarn[39m: Instead, please use another adapter like sails-postgresql or sails-mongo.
[33mwarn[39m: For more info, see: http://sailsjs.com/docs/concepts/deployment
[33mwarn[39m: To hide this warning message, enable `sails.config.orm.skipProductionWarnings`.
[33mwarn[39m:  [?] If you're unsure, see https://sailsjs.com/support
[32minfo[39m: 
[32minfo[39m:                .-..-.
[32minfo[39m: 
[32minfo[39m:    Sails              <|    .-..-.
[32minfo[39m:    v1.2.2              |\
[32minfo[39m:                       /|.\
[32minfo[39m:                      / || \
[32minfo[39m:                    ,'  |'  \
[32minfo[39m:                 .-'.-==|/_--'
[32minfo[39m:                 `--'-------' 
[32minfo[39m:    __---___--___---___--___---___--___
[32minfo[39m:  ____---___--___---___--___---___--___-__
[32minfo[39m: 
[32minfo[39m: Server lifted in `/usr/src/app`
[32minfo[39m: To shut down Sails, press <CTRL> + C at any time.
[32minfo[39m: Read more at https://sailsjs.com/support.
[34mdebug[39m: -------------------------------------------------------
[34mdebug[39m: :: Thu Sep 05 2019 06:22:35 GMT+0000 (Coordinated Universal Time)
[34mdebug[39m: Environment : production
[34mdebug[39m: Port        : 1337
[34mdebug[39m: -------------------------------------------------------
我在
config/env/production.js中通过添加
hookTimeout:300000

我假设超时以毫秒为单位,因此我将超时设置为5分钟。然而,根据新的日志,帆船只需等待2分钟。我是否正确地增加了超时

更新:

我怀疑,资产的建设有助于解决问题。作为构建Docker映像的一部分,我通过预编译资产将启动时间从6分钟以上缩短到3分钟

  • tasks/register/prod.js
    复制到
    tasks/register/docker-prod.js
    (或任何您想要的)并重命名任务以匹配文件名(例如:
    docker-prod
  • 创建/编辑
    任务/register/prod.js
    以包含
  • 将以下内容添加到您的
    Dockerfile

  • 为什么要在生产中使用内存存储。js@VikasKumar对于这个特殊的环境,,正如日志所述,
    sails disk
    /
    MemoryStore
    我想知道这是否是因为容器的文件系统是EBS卷,因此网络延迟或其他AWS环境设置导致启动延迟。为什么在生产中使用内存存储。js@VikasKumar对于这个特殊的环境,,正如日志所说,
    sails disk
    /
    MemoryStore
    我想知道这是否是因为容器的文件系统是EBS卷,因此网络延迟或其他AWS环境设置导致启动延迟。
    2019-09-14T11:17:29.226Z warn:  [?] If you're unsure, see https://sailsjs.com/support
    2019-09-14T11:19:29.084Z error: Failed to lift app:Sails is taking too long to load.
    
    --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --
     Troubleshooting tips:
      -• Were you still reading/responding to an interactive prompt?
         (Whoops, sorry!  Please lift again and try to respond a bit more quickly.)
    
      -• Do you have a lot of stuff in `assets/`?  Grunt might still be running.
        (Try increasing the hook timeout.  Currently it is 300000.
         e.g. `sails lift --hookTimeout=600000`)
    
      -• Is `grunt` a custom or 3rd party hook?
        (*If* `initialize()` is using a callback, make sure it's being called.)
    --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --
    
    // don't build assets as part of running prod; 'docker-prod' instead
    grunt.registerTask('prod', []);
    
    # Build the assets for Docker
    RUN ./node_modules/.bin/grunt docker-prod