Repository navigation
Conversation
e777e20 to
7f316f3
Compare
7f316f3 to
1db50cc
Compare
| BUILD_PROJECT=${BUILD_PROJECT:-webhook-build} | ||
| REGISTRY=${REGISTRY:-icr.io/codeengine/webhook-sample} | ||
|
|
||
| ibmcloud ce project get --name "$BUILD_PROJECT" > /dev/null 2>&1 || ibmcloud ce project create --name "$BUILD_PROJECT" | ||
| ibmcloud ce project select --name "$BUILD_PROJECT" | ||
|
|
||
| suffix=$(date +%y%m%d-%H%M%S) | ||
| ibmcloud ce buildrun submit --name "webhook-consumer-$suffix" --source src/consumer --strategy dockerfile \ | ||
| --image "$REGISTRY/consumer" --wait | ||
| ibmcloud ce buildrun submit --name "webhook-receiver-$suffix" --source src/receiver --strategy codebundle-nodejs-24 \ | ||
| --dockerfile "" --image "$REGISTRY/receiver" --wait |
There was a problem hiding this comment.
This will potentially break automation, as the automation only has a Container Registry Context and no ability to select a certain project.
There was a problem hiding this comment.
We should discuss if adding a Code Engine context would be viable. Would be great if the automation was able to submit build runs, also for other function samples requiring code bundles.
| ibmcloud ce project create --name "$ISOLATED_PROJECT" | ||
| ISOLATED_GUID=$(ibmcloud ce project get --name "$ISOLATED_PROJECT" --output json | jq -r '.guid') | ||
| ibmcloud cbr rule-create --description "Block all inbound traffic to $ISOLATED_PROJECT" \ | ||
| --service-name codeengine --service-instance "$ISOLATED_GUID" \ | ||
| --api-types crn:v1:bluemix:public:context-based-restrictions::::api-type:data-plane \ | ||
| --empty-context-list | ||
|
|
||
| # Trusted profiles: the receiver may only write to the bucket, the consumer may only read from it | ||
| PUBLIC_TRUSTED_PROFILE_ID=$(ibmcloud iam trusted-profile-create "$PROFILE_PUBLIC" --output json | jq -r '.id') | ||
| ISOLATED_TRUSTED_PROFILE_ID=$(ibmcloud iam trusted-profile-create "$PROFILE_ISOLATED" --output json | jq -r '.id') | ||
| ibmcloud iam trusted-profile-policy-create "$PROFILE_PUBLIC" --roles "Object Writer" --service-name cloud-object-storage \ | ||
| --service-instance "$COS_GUID" --resource-type bucket --resource "$BUCKET" | ||
| ibmcloud iam trusted-profile-policy-create "$PROFILE_ISOLATED" --roles "Object Reader" --service-name cloud-object-storage \ | ||
| --service-instance "$COS_GUID" --resource-type bucket --resource "$BUCKET" |
There was a problem hiding this comment.
We should make this script idempotent.
There was a problem hiding this comment.
I had thought about this as well, but ended up finding real idempotency too complex. However, it looks like most run scripts in this repo provide idempotency by running clean() first before deploying. I will follow the same pattern for this run script.
This adds a new sample that shows a pattern for receiving webhooks from the public internet in a network-isolated Code Engine application.