This repository contains samples for how to use IBM Cloud Code Engine.
These samples are designed such that they should be able to be fully built and used by anyone. Unless otherwise noted the overall pattern that will be followed is:
- a
build
script shows how each container image used in the sample is built. By default, the script will push the image to theibmcom
namespace on DockerHub, so to use this yourself you'll need to set theREPOSITORY
environment variable to your own registry and/or namespace. - a
run
script will execute the sample. Most will also include logic to verify the output to ensure everything is working as expected. As withbuild
, it will default to using theibmcom
container images, so to use your own you'll need to set theREPOSITORY
environment variable. This means that you should be able to just executerun
without runningbuild
first, and it'll just use the pre-built images fromibmcom
.- invoking
run clean
should clean up from any previous execution without re-running the sample.
- invoking
Most samples will try to be relatively small to focus on one particular task so that it can be re-used easily and integrated into a larger use-case.
It is assumed that the following are installed:
- IBM Cloud command line (
ibmcloud
) - Code Engine plugin (
ce
) kubectl
for the rare sample that might need to dive really deep behind the scenesdocker
if you choose to build the images yourself
It is also assumed that you have a Code Engine project already created and selected, e.g.:
$ ic ce project create --name demos --select
- hello
Very basic "hello world!" type of application written in Node.js. Start here! - helloworld
Similar to hello except this is written in golang and adds a few bells-n-whistles to allow you to control what it does when invoked. - bind-app
This will create an instance of DB2 in the IBM Cloud and then ask Code Engine to bind it to an Application so we can access it from the App. The credentials, etc. will be injected into the App via environment variables.
- job
This will create a Batch Job that will print basic debugging information to the logs, and then show those logs. It'll create the Batch Job with and without a Job definition to show both options. - app-n-job
This will use the same image for both an Application and a Batch Job. Just to show that it's possible. - app2job
This will show how to submit a Job from an Application based on an incoming HTTP request to the Application. - bind-job
This will create an instance of DB2 in the IBM Cloud and then ask Code Engine to bind it to a Batch Job so we can access it from the Job. The credentials, etc. will be injected into the Job via environment variables. - job2app
This will demostrate how to create a simple Batch Job and how to have it communicate with an Application running within the same project.
- s2i-buildpacks
This will show how to use the source-to-image feature of Code Engine to build an Application from a git repo (using a Buildpack), push it to a private registry, and then deploy an Application using that image. - s2i-dockerfile
This will show how to use the source-to-image feature of Code Engine to build an Application from a git repo (using a Dockerfile), push it to a private registry, and then deploy an app using that image.
- ping
This will show how to setup a simple Ping(cron) Event Source and send its events to an Application.
- configmaps
Shows how to define and inject a ConfigMap as environment variables into an Application. - secrets
Shows how to define and inject a Secret as environment variables into an Application. - sessions
Starts a stateful application that scales based on load. The state is kept in an instance of Redis, also running within Code Engine. Demonstrates the use of non-http components and private networking between components.
- IBM Cloud Code Engine
- For questions/comments join us on Slack:
Register | Login and join us on the #code-engine channel