Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(website): support env var configs #171

Merged
merged 2 commits into from
Sep 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions website/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,18 @@ To do this, you must [configure Google as an Identity Platform](https://cloud.go
some - _but not all_ - application pages.

### Configuration
To configure the app, first rename `config.default.py` to `config.py`.

Then, specify the following values in `config.py`:
- Your Firebase API key
- Your Firebase Auth domain

You can determine these values by vising the
[Identity Providers page](https://console.cloud.google.com/customer-identity/providers) and clicking on the `Application Setup Details` button.
To configure the app, set the following environment variables:

---------------------------------------------------------------------------------------------
| **Variable name** | **Description** |
| `EMBLEM_FIREBASE_API_KEY` | The Firebase API key provided by Cloud Identity Platform. |
| `EMBLEM_FIREBASE_AUTH_DOMAIN` | The auth domain (usually of the form `*.firebaseapp.com`) |
| `EMBLEM_API_URL` | A URL pointing to your instance of the Emblem Content API |
---------------------------------------------------------------------------------------------

You can determine the `EMBLEM_FIREBASE_*` values by vising the
[Identity Providers page](https://console.cloud.google.com/customer-identity/providers) and clicking on the `Application Setup Details` button. The `EMBLEM_API_URL` value will be determined
by where you host the Content API. (If you're using Cloud Run, it will look something like `https://<SERVICE_NAME>-<HASH>.run.app`)

Congratulations! You are now ready to run the Emblem web app.

Expand Down
16 changes: 11 additions & 5 deletions website/config.default.py → website/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,20 @@
# limitations under the License.


###################################################
# TODO(developer): update the values in this file #
###################################################
import os


####################################################
# TODO(developer): set these environment variables #
####################################################


# The (public!) API key used by Firebase.
# This should be of the format "AIza..."
FIREBASE_API_KEY = "YOUR_FIREBASE_API_KEY"
FIREBASE_API_KEY = os.getenv("EMBLEM_FIREBASE_API_KEY")

# The domain name used by Firebase Auth
FIREBASE_AUTH_DOMAIN = "YOUR_APP.firebaseapp.com"
FIREBASE_AUTH_DOMAIN = os.getenv("EMBLEM_FIREBASE_AUTH_DOMAIN")

# The URL the Emblem Content API is hosted at
API_URL = os.getenv("EMBLEM_API_URL")
4 changes: 2 additions & 2 deletions website/views/campaigns.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@

from sample_data import SAMPLE_DONATIONS

from config import API_URL

from flask import Blueprint, redirect, request, render_template

import requests

campaigns_bp = Blueprint("campaigns", __name__, template_folder="templates")

API_URL = "https://api-pwrmtjf4hq-uc.a.run.app"


@campaigns_bp.route("/")
def list_campaigns():
Expand Down