The epg-ui is an extremely simple static website that is used for emulating an EPG for demo purposes. It provides a mock EPG where users can click elements. Some lightweight JavaScript then calls the epg-ui to fetch an URL for the synthesised audio, which is then played back to the user.
The EPG is pre-populated with random movies sourced from Google Play Movies. The content shown in the EPG can be changed by editing the src/epg-items.json file. This file should contain exactly 23 epgItems
.
The get-speech-service API URL can be changed on the epg-ui directly. To change the default value, you should edit the following line in src/index.html:
<input type="text" id="get-speech-service-api-endpoint" value="https://api.epg-text-to-speech.demos.maynard.io/getSpeech" class="form-control" id="session-key">
This will be made a configurable environment variable in the future.
Continuous deployment can be set up through Cloud Build. A sample cloudbuild.yaml file can be found in this directory. See here for instructions on how to set up a Build Trigger.
- These instructions assume that you are using a Bash Shell, and that you have gcloud installed and authenticated.
- Set variables:
PROJECT_ID=<PROJECT_ID>
CLOUD_RUN_REGION=<REGION>
Variable Explanation
Variable | Description |
---|---|
PROJECT_ID | The Google Cloud Project ID to deploy the resources in. |
CLOUD_RUN_REGION | The region to deploy the Cloud Run Services in (see: Cloud Run locations). |
- Set gcloud project and additional variables:
glcoud config set project ${PROJECT_ID}
PROJECT_NUMBER=$(gcloud projects describe ${PROJECT_ID} --format="value(projectNumber)")
gcloud services enable compute.googleapis.com cloudbuild.googleapis.com run.googleapis.com containerregistry.googleapis.com
Do not complete this step if setting up a local development environment
gcloud builds submit --tag gcr.io/${PROJECT_ID}/epg-ui:latest .
gcloud iam service-accounts create epg-ui-sa --description="Service Account for the epg-ui"
Do not complete this step if setting up a local development environment
- Run the following command (tweak config as appropriate. See gcloud run deploy docs)
gcloud run deploy epg-ui \
--image=gcr.io/${PROJECT_ID}/epg-ui:latest \
--region=${CLOUD_RUN_REGION} \
--port=80
--platform=managed \
--concurrency=80 \
--cpu=2 \
--memory=1Gi \
--timeout=20s \
--max-instances=100 \
--service-account=epg-ui-sa@$PROJECT_ID.iam.gserviceaccount.com \
--allow-unauthenticated
- Grant Cloud Build permissions to deploy to Cloud Run, and to use the required Service Accounts.
gcloud projects add-iam-policy-binding $PROJECT_ID --member serviceAccount:[email protected] --role='roles/run.admin'
gcloud iam service-accounts add-iam-policy-binding [email protected] --member="serviceAccount:[email protected]" --role='roles/iam.serviceAccountUser'
gcloud iam service-accounts add-iam-policy-binding epg-ui-sa@$PROJECT_ID.iam.gserviceaccount.com --member="serviceAccount:[email protected]" --role='roles/iam.serviceAccountUser'
See here
- Set Environment
EPG_UI_FQDN=<FQDN>
Variable Explanation
Variable | Description |
---|---|
EPG_UI_FQDN | The custom URL you want to use for the epg-ui Cloud Run Service (e.g. epg-ui.demos.maynard.io ) |
- Create Domain Mapping
gcloud beta run domain-mappings create --service epg-ui --domain ${EPG_UI_FQDN} --platform=managed --region=${CLOUD_RUN_REGION}
-
Login to your DNS provider, and create a DNS record as described in the above command output
-
Monitor the status of the Domain Mapping
gcloud beta run domain-mappings list --platform=managed --region=${CLOUD_RUN_REGION}
Developing locally requires docker-compose.
A docker-compose.yml file is included in this directory to simplify the configuration when testing locally. You should create a separate development project in Google Cloud and follow all of the steps above, with the exception of deploying the image to Cloud Run. Once complete, perform the following steps for local development.
docker-compose build && docker-compose up -d
docker-compose ps
- Visit https://localhost:8009