How do you call db:seed on AWS Elastic Beanstalk apps?

后端 未结 5 710
挽巷
挽巷 2021-02-07 14:18

I know that you can run tasks as part of each deploy, but I only want to bootstrap the database once.

5条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-07 14:52

    Kristian's answer is close, but you should also add:

    container_commands:
      seeddb:
        command: 'export HOME=/root; rake db:seed'
        leader_only: true
    

    So that the DB is only seeded from 1 EC2 instance, rather than all of them at the same time. Depending on your EB deployment/version, the export HOME may or may not be needed.

提交回复
热议问题