LoginSignup
4
2

More than 1 year has passed since last update.

Google App Engine Standard Environment で berglas を使う

Last updated at Posted at 2019-11-27

GAE SE での berglas の使い方

gcloud app deploy コマンドでデプロイをするとカレントディレクトリ以下のファイルが全て GAE に転送されるので、あらかじめ berglas のバイナリをダウンロードしておいて、gcloud app deploy すればよい。

curl -o ./berglas https://storage.googleapis.com/berglas/master/linux_amd64/berglas
chmod a+x berglas
gcloud app deploy

GAE SE の環境は linux x86_64 なので linux_amd64 をダウンロードすれば良い (補足: entrypoint に uname -a コマンドなどを書いてデプロイしてみて環境情報を調べた)

これで app.yaml の entrypoint で ./berglas exec -- のように使えるようになる。

runtime: nodejs10
entrypoint: ./berglas exec -- npm start
env_variables:
  NODE_ENV: 'production'
  DB_USERNAME: berglas://{BUCKET_ID}/db-username
  DB_PASSWORD: berglas://{BUCKET_ID}/db-password

おまけ: Java アプリの場合

mvn appengine:deploy でデプロイするとビルド && ステージング && デプロイまで一気に実行される。余計なファイルは消されてしまうので berglas をおく隙がない。

mvn appengine:stage でビルド && ステージングまでしておいて、berglas を配置して、gcloud app deploy でデプロイすれば良い。

mvn clean package appengine:stage
cd target/appengine-staging
curl -o ./berglas https://storage.googleapis.com/berglas/master/linux_amd64/berglas
chmod a+x berglas
gcloud app deploy
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