kth serverless demo
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
#!/bin/bash | |
set -xe | |
# Meant to be run in cloud shell | |
# Enable APIs if not already done | |
# gcloud services enable run.googleapis.com containerregistry.googleapis.com | |
echo | |
echo "download container image locally" | |
echo | |
docker pull esimov/pigo-openfaas:0.1 | |
# if running this script on a non-CloudShell vm | |
# gcloud auth configure-docker | |
# gcloud components install docker-credential-gcr | |
export PROJECT_ID=$(gcloud config get-value project) | |
export IMAGE="eu.gcr.io/${PROJECT_ID}/pigo-openfaas:latest" | |
echo | |
echo "Tag container image" | |
echo | |
docker tag esimov/pigo-openfaas:0.1 "${IMAGE}" | |
echo | |
echo "Push container image to gcr" | |
echo | |
docker push "${IMAGE}" | |
echo | |
echo "Deploy container on Cloud Run" | |
echo | |
gcloud run deploy pigo-openfaas --platform=managed \ | |
--region=us-central1 --image="${IMAGE}" \ | |
--allow-unauthenticated \ | |
--set-env-vars=output_mode=image \ | |
--set-env-vars=input_mode=url | |
echo | |
echo "Get the service URL endpoint" | |
echo | |
export FUNCTION_URL=$(gcloud run services describe pigo-openfaas --region=us-central1 --platform=managed --format=json | jq -r '.status.url') | |
echo | |
echo "Choose an image to do face detection on" | |
echo | |
export IMG_URL="https://upload.wikimedia.org/wikipedia/commons/thumb/c/cc/NASA_Astronaut_Group_18.jpg/1200px-NASA_Astronaut_Group_18.jpg" | |
sleep 5 | |
echo | |
echo "Using the deployed services" | |
echo | |
curl -H 'Content-Type: binary/octet-stream' \ | |
--data-binary "${IMG_URL}" "${FUNCTION_URL}" > target.jpg | |
echo | |
echo "Done." | |
echo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment