The package executable has been built and added to the example until the
functionsframework
is published.
- Set env var "GCP_PROJECT" to our project name:
GCP_PROJECT=$(gcloud config list --format 'value(core.project)' 2>/dev/null)
- Build and upload your image in Google Container Registry:
gcloud builds submit \
--tag gcr.io/$GCP_PROJECT/hello-r \
--timeout="20m"
- Deploy your container to Cloud Run:
gcloud run deploy hello-r \
--image gcr.io/$GCP_PROJECT/hello-r \
--platform managed \
--allow-unauthenticated
- Test out your app:
curl https://hello-r-HASH-uc.a.run.app
# Output
["Hello World!"]
- Update the Dockerfile with
ENTRYPOINT
:
ENTRYPOINT [ "Rscript", "create-app.R", "--target", "HelloEvent", "--source", "event.R", "--signature_type", "event" ]
-
Follow the above steps to build and deploy.
-
Test out your app:
curl -H 'content-type: application/json' \
-X POST \
--data $'{"context": { "eventId": "some-eventId", "timestamp": "some-timestamp", "eventType": "some-eventType", "resource": "some-resource"},"data": {"filename": "filename.txt", "value": "some-value"}}' \
https://hello-r-HASH-uc.a.run.app
# Output
["Hello Event!"]