This repo contains the Uploader app that is deployed in Cloud Run. To run the whole Storage connector, you will also need the Trigger function to be deployed in Cloud Function.
GCS Connector uploads files on WizyVision, on every files that will be uploaded in the source GCS bucket.
- Google Cloud project
- WizyVision account
- Cloud Storage bucket
- Enable the APIs required
gcloud services enable \
cloudfunctions.googleapis.com \
pubsub.googleapis.com \
cloudbuild.googleapis.com \
artifactregistry.googleapis.com \
containerregistry.googleapis.com \
run.googleapis.com \
--quiet
- Grant the pubsub.publisher role to the Cloud Storage service account. This will allow the service account to publish events when images are uploaded into the bucket.
SERVICE_ACCOUNT="$(gsutil kms serviceaccount -p GOOGLE_CLOUD_PROJECT_ID_HERE)"
gcloud projects add-iam-policy-binding GOOGLE_CLOUD_PROJECT_ID_HERE \
--member="serviceAccount:${SERVICE_ACCOUNT}" \
--role='roles/pubsub.publisher'
- Install docker for Manual installation.
After successful deployment (applies for both using Cloud Run Button and Manual Installation), navigate to GCP IAM & Admin and find the default compute service account created.
Add these roles to the default service account:
- Storage Object Viewer
- Cloud Run Developer
- Clone this repository.
git clone https://github.com/sephdiza/gcs-connector.git
- Create a file named
.env
at the root of this folder. Copy the contents ofplaceholder.env
and set the values.
# GCP
GOOGLE_CLOUD_PROJECT="<INPUT_YOUR_PROJECT_NAME_HERE>"
# Path where you put the service account file
GOOGLE_APPLICATION_CREDENTIALS_PATH="./secrets/service-account.json"
# WizyVision
# The application API key
WV_BEARER_API_KEY="<INPUT_WIZYVISION_APP_BEARER_API_KEY_HERE>"
# Public API url of your account
WV_PUBLIC_API_URL="https://mywizyvisiondomain.eu.wizyvision.app/api/v1/public/files"
# Comma-separated list of Tag IDs to set for the uploaded files
TAG_IDS=""
# Privacy to set for the uploaded files, Standard if this is left empty
PRIVACY_ID=""
# Header and token to be authenticated to call the Uploader service
UPLOADER_SERVICE_AUTH_HEADER="Wizdam-Dev-Csc-Token"
UPLOADER_SERVICE_AUTH_TOKEN=""
# Slack used for notification when errors are encountered. Can be left blank
SLACK_BEARER_TOKEN=""
SLACK_CHANNEL_ID=""
- Build the image.
docker build -t IMAGE_NAME .
- Push the image to the container registry.
docker tag IMAGE_NAME gcr.io/PROJECT_NAME_HERE/IMAGE_NAME
docker push gcr.io/PROJECT_NAME_HERE/IMAGE_NAME
- Deploy to cloud run.
gcloud run deploy IMAGE_NAME \
--project PROJECT_NAME \
--image IMAGE_URL \
--region REGION \
--allow-unauthenticated \
--memory=256Mi \
--max-instances=10
- Take note of the URL of the service after successfully deploying. This will be needed in the Trigger service deployment.
Note: The Trigger function should already be deployed
- Upload files on the GCS bucket
- In WizyVision webapp, you should see the file uploaded there with the correct tags and privacy set during the deployment