Code samples, tutorials, blog posts, and more for IBM Cloud Code Engine.
Code Samples
# Create the app
ibmcloud ce app create -n helloworld --image ${REGISTRY}/helloworld
# Get the URL of the app for later use
URL=$(ibmcloud ce app get -n helloworld -o url)
# Now call it
curl -w "\n%{http_code}\n" -fs $URL | tee out
async function runBatchJob(
projectId: string,
imageRef: string,
envVars: Record<string, string>
): Promise<string> {
// Create job definition
await codeEngineClient.createJob({
projectId,
name: "data-processor",
});
}
async function subscribeToStorage(
projectId: string,
appName: string,
bucketName: string
) {
const subscription = await
codeEngineClient.createSubscriptionCos({
projectId,
name: `cos-trigger-${bucketName}`,
destination: {
name: appName,
type: "app"
},
source: { bucket: bucketName },
});
}
async function buildFromSource(
projectId: string,
repoUrl: string,
outputImage: string
) {
// create build config
await codeEngineClient.createBuild({
projectId,
name: "my-build",
outputImage,
sourceUrl: repoUrl,
strategyType: "dockerfile",
});
}
# Log in and target a project
ibmcloud login --sso
ibmcloud ce project select --name my-project
# Deploy an app from a public image
ibmcloud ce app create \
--name hello \
--image icr.io/codeengine/hello \
--min-scale 0 --max-scale 10
ibmcloud ce app create \
--name my-translator \
--build-source . \
--build-size xlarge \
--ephemeral-storage 4G \
--memory 4G \
--cpu 2 \
--scale-down-delay 600 \
--probe-ready type=http \
--probe-ready path=/api/ping \
--probe-ready interval=5 \
--probe-ready initial-delay=10 \
--probe-ready timeout=3
Technical Blogs