Firebase Dev Day 2019 - Building dynamic website by Firebase Hosting x Cloud Run
Build
docker build -t asia.gcr.io/gear2019v2/firebase-dev-day-2019:latest .
Run
docker run -p 8080:8080 asia.gcr.io/gear2019v2/firebase-dev-day-2019:latest
Run with local source
docker run --mount type=bind,source="$(pwd)",target=/var/www/html -p 8080:8080 asia.gcr.io/gear2019v2/firebase-dev-day-2019:latest
gcloud builds submit --tag asia.gcr.io/gear2019v2/firebase-dev-day-2019:latest
gcloud beta run deploy --image asia.gcr.io/gear2019v2/firebase-dev-day-2019:latest --platform managed
-
Dev PHP App
-
Build Docker (PHP + Apache)
-
Build Docker image locally.
docker build -t asia.gcr.io/gear2019v2/firebase-dev-day-2019:latest .
-
Optional - Config gcloud. https://cloud.google.com/sdk/docs/ Configure Docker to use Google Cloud Platform
gcloud auth configure-docker
-
Push the image to GCR.
docker push asia.gcr.io/gear2019v2/firebase-dev-day-2019:latest
-
Deploy to Cloud Run.
gcloud beta run deploy gear2019v2-firebase-dev-day-2019 \ --quiet \ --image asia.gcr.io/gear2019v2/firebase-dev-day-2019:latest \ --project gear2019v2 \ --region asia-northeast1 \ --platform managed \ --allow-unauthenticated
-
Create a new site on console, name
fir-dev-day-2019
-
Set up deploy targets
firebase target:apply hosting gear2019v2 gear2019v2 firebase target:apply hosting fir-dev-day-2019 fir-dev-day-2019
-
Add rewrites config
{ ... "hosting": [ {}, ... { "target": "fir-dev-day-2019", "public": "fir-dev-day-2019/public", "ignore": [ "firebase.json", "**/.*", "**/node_modules/**" ], "rewrites": [ { "source": "**", "run": { "serviceId": "gear2019v2-firebase-dev-day-2019", "region": "asia-northeast1" } } ] }, ... ] }
To listing Firebase project
firebase projects:list
-
Deploy
firebase deploy --only hosting:fir-dev-day-2019
https://cloud.google.com/run/docs/quickstarts/build-and-deploy
https://cloud.google.com/container-registry/docs/pushing-and-pulling
https://cloud.google.com/sdk/gcloud/reference/beta/run/deploy