-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from CupOfGeo/tf-docs
Tf docs
- Loading branch information
Showing
30 changed files
with
538 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
# This workflow build and push a Docker container to Google Artifact Registry and deploy it on Cloud Run when a commit is pushed to the "main" branch | ||
# | ||
# Overview: | ||
# | ||
# 1. Authenticate to Google Cloud | ||
# 2. Authenticate Docker to Artifact Registry | ||
# 3. Build a docker container | ||
# 4. Publish it to Google Artifact Registry | ||
# 5. Deploy it to Cloud Run | ||
# | ||
# To configure this workflow: | ||
# | ||
# 1. Ensure the required Google Cloud APIs are enabled: | ||
# | ||
# Cloud Run run.googleapis.com | ||
# Artifact Registry artifactregistry.googleapis.com | ||
# | ||
# 2. Create and configure Workload Identity Federation for GitHub (https://github.com/google-github-actions/auth#setting-up-workload-identity-federation) | ||
# | ||
# 3. Ensure the required IAM permissions are granted | ||
# | ||
# Cloud Run | ||
# roles/run.admin | ||
# roles/iam.serviceAccountUser (to act as the Cloud Run runtime service account) | ||
# | ||
# Artifact Registry | ||
# roles/artifactregistry.admin (project or repository level) | ||
# | ||
# NOTE: You should always follow the principle of least privilege when assigning IAM roles | ||
# | ||
# 4. Create GitHub secrets for WIF_PROVIDER and WIF_SERVICE_ACCOUNT | ||
# | ||
# 5. Change the values for the GAR_LOCATION, SERVICE and REGION environment variables (below). | ||
# | ||
# NOTE: To use Google Container Registry instead, replace ${{ env.GAR_LOCATION }}-docker.pkg.dev with gcr.io | ||
# | ||
# For more support on how to run this workflow, please visit https://github.com/marketplace/actions/deploy-to-cloud-run | ||
# | ||
# Further reading: | ||
# Cloud Run IAM permissions - https://cloud.google.com/run/docs/deploying | ||
# Artifact Registry IAM permissions - https://cloud.google.com/artifact-registry/docs/access-control#roles | ||
# Container Registry vs Artifact Registry - https://cloud.google.com/blog/products/application-development/understanding-artifact-registry-vs-container-registry | ||
# Principle of least privilege - https://cloud.google.com/blog/products/identity-security/dont-get-pwned-practicing-the-principle-of-least-privilege | ||
name: Build and Deploy to Cloud Run | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
|
||
env: | ||
PROJECT_ID: "geo-attractors" | ||
GAR_LOCATION: "us-central1" | ||
REGION: 'us-central1' | ||
REPO: 'attractors' | ||
|
||
jobs: | ||
deploy: | ||
permissions: | ||
contents: 'read' | ||
id-token: 'write' | ||
|
||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Google Auth | ||
id: auth | ||
uses: 'google-github-actions/auth@v1' | ||
with: | ||
token_format: 'access_token' | ||
workload_identity_provider: '${{ secrets.WIF_PROVIDER }}' # e.g. - projects/123456789/locations/global/workloadIdentityPools/my-pool/providers/my-provider | ||
service_account: '${{ secrets.WIF_SERVICE_ACCOUNT }}' # e.g. - [email protected] | ||
|
||
# Authenticate Docker to Google Cloud Artifact Registry | ||
- name: Login to GAR | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: '${{ env.GAR_LOCATION }}-docker.pkg.dev' | ||
username: 'oauth2accesstoken' | ||
password: ${{ steps.auth.outputs.access_token }} | ||
|
||
- name: Build and Push Backend | ||
run: |- | ||
cd backend/ | ||
docker build --target BUILD -t "${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPO }}/attractors-backend:latest" ./ | ||
docker push "${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPO }}/attractors-backend:latest" | ||
- name: Build and Push Frontend | ||
run: |- | ||
cd frontend/ | ||
docker build --target BUILD -t "${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPO }}/attractors-frontend:latest" ./ | ||
docker push "${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPO }}/attractors-frontend:latest" | ||
# END - Docker auth and build | ||
|
||
- name: Deploy Backend to Cloud Run | ||
id: deploy | ||
uses: google-github-actions/deploy-cloudrun@v2 | ||
with: | ||
service: attractors-backend-service | ||
region: ${{ env.REGION }} | ||
# NOTE: If using a pre-built image, update the image name here | ||
image: ${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPO }}/attractors-backend:latest | ||
|
||
# If required, use the Cloud Run url output in later steps | ||
- name: Show Backend URL | ||
run: echo ${{ steps.deploy.outputs.url }} | ||
|
||
- name: Deploy Frontend to Cloud Run | ||
id: deploy-frontend | ||
uses: google-github-actions/deploy-cloudrun@v2 | ||
with: | ||
service: attractors-frontend-service | ||
region: ${{ env.REGION }} | ||
# NOTE: If using a pre-built image, update the image name here | ||
image: ${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPO }}/attractors-frontend:latest | ||
|
||
- name: Show Frontend URL | ||
run: echo ${{ steps.deploy-frontend.outputs.url }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
This backend uses FastAPI. | ||
|
||
`gcloud builds submit --tag "us-central1-docker.pkg.dev/geo-attractors/attractors/attractors-backend" --ignore-file .dockerignore` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,49 @@ | ||
aiocache==0.12.2 | ||
annotated-types==0.6.0 | ||
anyio==4.2.0 | ||
certifi==2023.11.17 | ||
charset-normalizer==3.3.2 | ||
click==8.1.7 | ||
cloudpickle==3.0.0 | ||
colorcet==3.0.1 | ||
dask==2023.12.1 | ||
datashader==0.16.0 | ||
fastapi==0.108.0 | ||
fsspec==2023.12.2 | ||
h11==0.14.0 | ||
idna==3.6 | ||
importlib-metadata==7.0.1 | ||
llvmlite==0.41.1 | ||
locket==1.0.0 | ||
loguru==0.7.2 | ||
multipledispatch==1.0.0 | ||
numba==0.58.1 | ||
numpy==1.26.3 | ||
orjson==3.9.10 | ||
packaging==23.2 | ||
pandas==2.1.4 | ||
param==2.0.1 | ||
partd==1.4.1 | ||
pillow==10.2.0 | ||
prometheus-client==0.19.0 | ||
prometheus-fastapi-instrumentator==6.1.0 | ||
pyct==0.5.0 | ||
pydantic==2.5.3 | ||
pydantic-settings==2.1.0 | ||
pydantic_core==2.14.6 | ||
python-dateutil==2.8.2 | ||
python-dotenv==1.0.0 | ||
pytz==2023.3.post1 | ||
PyYAML==6.0.1 | ||
requests==2.31.0 | ||
scipy==1.11.4 | ||
six==1.16.0 | ||
sniffio==1.3.0 | ||
starlette==0.32.0.post1 | ||
toolz==0.12.0 | ||
typing_extensions==4.9.0 | ||
tzdata==2023.4 | ||
urllib3==2.1.0 | ||
uvicorn==0.25.0 | ||
xarray==2023.12.0 | ||
zipp==3.17.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.