How to run sequelize db:migrate on Elastic Beanstalk EB with env vars? How to access .env vars in container commands?

前端 未结 3 1493
梦如初夏
梦如初夏 2021-01-22 04:56

How can I run sequelize db:migrate on ElasticBeanstalk with env vars?

Running sequelize migrate fails since it cannot find the .env file.<

3条回答
  •  一生所求
    2021-01-22 05:24

    Don't forget to include the first two commands, the file migration.config that worked for me in .ebextensions looks like this

    container_commands:
      00_node_binary:
        command: "ln -sf `ls -td /opt/elasticbeanstalk/node-install/node-* | head -1`/bin/node /bin/node"
      00_npm_binary:
        command: "ln -sf `ls -td /opt/elasticbeanstalk/node-install/node-* | head -1`/bin/npm /bin/npm"
      50-run-database-migrations:
        command: "./node_modules/.bin/sequelize db:migrate"
        leader_only: true
    

    It looks like the ./node_modules/.bin/sequelize uses /usr/bin/env/node and will give you the following error:

    /usr/bin/env: node: No such file or directory
    

    Because apparently node is called nodejs... the first two container commands will take care of that.

    See https://github.com/nodejs/node-v0.x-archive/issues/3911 for further reference

提交回复
热议问题