LoginSignup
4
2

More than 5 years have passed since last update.

Elastic Beanstalkにgit submoduleの内容を含めてデプロイする

Last updated at Posted at 2016-09-02

eb deployコマンドではまったこと。

  • eb deployは、git archiveでzipを作り、それをアップロードする
  • しかしgit archiveはsubmoduleの内容を含まない
  • 自分はgolang + docker環境へデプロイしようとしていたが、submoduleの中身がないので当然ビルドできず、デプロイがこける

どうしたものかと悩んだ挙句、これが一番簡単で良いかなと思いました。

  • eb deployでgit archiveさせない
  • 必要なソースを含むzipを自分で作る
  • .elasticbeanstalk/config.ymlに、デプロイするzipファイルを指定する

.elasticbeanstalk/config.yml

  • プロジェクトルートの.elasticbeanstalk/config.ymlに以下の行を追加します
config.yml
deploy:
  artifact: deploy.zip

deploy.zipを作成する

自分はgolangなので必要なファイル&フォルダは以下のとおり

main.go main()を含む
Dockerfile デプロイ後にBeanstalkがDocker環境を用意するためのDockerfile
vendor/* 各種ソース

この場合、zipコマンドで以下のようにzipを作ればいい

zip -r deploy.zip Dockerfile main.go vendor

デプロイする

上記のようにdeploy.zipを作ったら、eb deployすればいいだけ。Beanstalk上でgit submoduleはどこでやればいいのとか悩む必要は無かった。

あとsubmoduleの件以外に、この方法が良いと思ったことは、git commitしなくてもeb deployできること。"You have uncommitted changes."とWarningは出るけど、未コミットの内容含めてデプロイできる。うまく動かなくてハマっている時にトライアンドエラーしやすくて良いです。

4
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
2