-
Notifications
You must be signed in to change notification settings - Fork 71
feat: migrate postdeployment to data http #123
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
Changes from all commits
6fb537e
10a979e
2e55250
17dea67
7af2799
551c6dd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| # Copyright 2023 Google LLC | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| FROM gcr.io/google.com/cloudsdktool/cloud-sdk:slim | ||
| COPY init-execute.sh . | ||
| ENTRYPOINT ./init-execute.sh |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| # Init | ||
|
|
||
| This folder contains the source for a container image that runs the tasks required to setup the application on first deployment. | ||
|
|
||
| The container is designed to be executed as a Cloud Run job, with the `roles/run.developer` role, to run the `init-execute.sh` script: | ||
|
|
||
| * execute the `setup` job, [primes the the database](https://github.com/GoogleCloudPlatform/avocano/blob/main/server/scripts/prime_database.sh) script | ||
| * execute the `client` job, that runs the [client deployment](https://github.com/GoogleCloudPlatform/avocano/blob/main/client/docker-deploy.sh) | ||
| * purges cache and warms API. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| #!/bin/bash | ||
| # Copyright 2023 Google LLC | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| # Script to assist in Dockerfile-based deployments. | ||
| # any errors? exit immediately. | ||
| set -e | ||
|
|
||
| # escape if project_id not defined (mandatory, required later) | ||
| if [[ -z $PROJECT_ID ]]; then | ||
| echo "PROJECT_ID not defined. Cannot deploy. Exiting." | ||
| exit 1 | ||
| fi | ||
|
|
||
| # escape if firebase_url not defined (mandatory, required later) | ||
| if [[ -z $FIREBASE_URL ]]; then | ||
| echo "FIREBASE_URL not defined. Cannot deploy. Exiting." | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Define common defaults, all overrideable. | ||
| REGION="${REGION:-us-central1}" | ||
| SETUP_JOB="${SETUP_JOB:-setup}" | ||
| CLIENT_JOB="${CLIENT_JOB:-client}" | ||
|
|
||
| echo "*** Executing initization job ***" | ||
| echo "PROJECT_ID: $PROJECT_ID" | ||
| echo "REGION: $REGION" | ||
| echo "SETUP JOB: $SETUP_JOB" | ||
| echo "CLIENT JOB: $CLIENT_JOB" | ||
| echo "FIREBASE URL: $FIREBASE_URL" | ||
| echo "SERVER URL: $SERVER_URL" | ||
| echo "" | ||
|
|
||
| echo "Running init database migration..." | ||
| gcloud run jobs execute "$SETUP_JOB" --wait --project "$PROJECT_ID" --region "$REGION" | ||
|
|
||
| echo "Running client deploy..." | ||
| gcloud run jobs execute "$CLIENT_JOB" --wait --project "$PROJECT_ID" --region "$REGION" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will this exit with a non-zero status code on failure?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it fires https://github.com/GoogleCloudPlatform/avocano/blob/main/client/docker-deploy.sh so in theory yes, if a failed firebase command returns the correct exit code. |
||
|
|
||
| echo "Purge Firebase cache" | ||
| echo curl -X PURGE "${FIREBASE_URL}/" | ||
|
|
||
| echo "Warm up API" | ||
| curl "${SERVER_URL}/api/products/?warmup" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| # Copyright 2023 Google LLC | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| # Build placeholder site code into container | ||
|
|
||
| steps: | ||
| - id: build | ||
| name: "gcr.io/cloud-builders/docker" | ||
| dir: app/init | ||
| args: | ||
| [ | ||
| "build", | ||
| "-t", | ||
| "gcr.io/$PROJECT_ID/$_IMAGE_NAME", | ||
| ".", | ||
| ] | ||
|
|
||
| images: | ||
| - gcr.io/$PROJECT_ID/$_IMAGE_NAME | ||
|
|
||
| substitutions: | ||
| _IMAGE_NAME: avocano-init | ||
|
|
||
| options: | ||
| dynamic_substitutions: true |
Uh oh!
There was an error while loading. Please reload this page.