feat: track firebase extension configuration in code

This commit is contained in:
Luke Watts
2023-10-01 09:41:20 +02:00
parent ead15c257f
commit 21655a42bd
6 changed files with 43 additions and 2 deletions

View File

@@ -43,6 +43,7 @@
"taskkill",
"teardown",
"Brevo",
"Sendinblue"
"Sendinblue",
"envsubst"
]
}

View File

@@ -8,5 +8,6 @@
"project-kamp-production": "project-kamp-community",
"fixing-fashion-development": "fixing-fashion-dev",
"fixing-fashion-production": "fixing-fashion-prod"
}
},
"targets": {}
}

1
extensions/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
*.env

30
extensions/README.md Normal file
View File

@@ -0,0 +1,30 @@
# Firebase Extensions Directory
Firebase Extensions are pre-packaged solutions that help you perform common tasks and integrate additional services into your Firebase project. Each extension in this directory is designed to address a specific use case or functionality, providing a seamless development experience.
## Handling configuration
We should not store sensitive information in the `*.config` files, instead
we can reference environmental variables, which will then be set in the `.env` file.
At the time of writing the firebase CLI does not support this, so we need to use [envsubst](https://www.gnu.org/software/gettext/manual/html_node/envsubst-Invocation.html) to populate the `.env` file.
The environmental variables required are:
- CP_SMTP_CONNECTION_URI: A connection URI for the SMTP server
The suggested convention is for each environment variable to be prefixed with `CP_`.
## Deploy extension
Populate a `.env` based on the `.config` for each extension. This can be done with the following command:
```bash
envsubst < extensions/firestore-send-email.config > extensions/firestore-send-email.env
```
Run the following command from the project root directory:
```bash
firebase deploy --only extensions [--project project_id]
```

View File

@@ -0,0 +1,5 @@
DEFAULT_FROM=community@preciousplastic.com
MAIL_COLLECTION=emails
SMTP_CONNECTION_URI=${CP_SMTP_CONNECTION_URI}
TTL_EXPIRE_TYPE=never
TTL_EXPIRE_VALUE=1

View File

@@ -118,5 +118,8 @@
},
"storage": {
"rules": "firebase.storage.rules"
},
"extensions": {
"firestore-send-email": "firebase/firestore-send-email@0.1.27"
}
}