4
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

LeveragesAdvent Calendar 2018

Day 22

firebaseのデプロイ時に最低限覚えておくべきこと

Last updated at Posted at 2018-12-21

雑多ですが

firebaseのコンフィギュレーション

firebase.json
{
  "functions": {
    "predeploy": [
      "npm --prefix \"$RESOURCE_DIR\" run lint",
      "npm --prefix \"$RESOURCE_DIR\" run build"
    ],
    "source": "functions"
  },
  "firestore": {
    "rules": "firestore.rules",
    "indexes": "firestore.indexes.json"
  },
  "storage": {
    "rules": "storage.rules"
  }
}

各、firebaseサービスの設定キーに対して、リソースファイルをセットすると、対応するコマンドでリソースの設定情報でデプロイが出来る。(rules,indexesなど)
本番環境でのデプロイ先誤認を防ぐため、productionだった時に、プロンプト入力を求めるバッチを入れることを推奨。

.firebaserc
{
  "projects": {
    "default": "sample-proj",
    "development": "sample-proj",
    "staging": "sample-proj-staging",
    "production": "sample-proj-production"
  }
}

firebase useコマンドで操作対象のfirebaseプロジェクトの切り替えができる。
keyはalias(例: firebase use development)

###基本

functionsを全てデプロイ

firebase deploy --only functions

functionsを単体でデプロイ

firebase deploy --only functions:${functionName}

消すとき

消したいfunctionをexportを消した状態でデプロイコマンド
おすすめはコメントアウトしてデプロイ

// export const onRegisterUser ...
firebase deploy --only functions

indexをlocalにexportしたい

firebase firestore:indexes > $filepath

indexまたはrulesをデプロイしたい

firebase deploy --only $serviceName:(rules or indexes)

例) firebase deploy --only firestore:rules

functionsの環境変数のget

firebase functions:config:get [keyName]

functionsの環境変数のset

firebase functions:config:set $keyName=$value
4
1
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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?