Deploying a Sample App on IBM Cloud Code Engine with CI/CD Toolchain
Discover how to create an open toolchain with IBM Cloud® Continuous Delivery and deploy your app on Code Engine. Explore how toolchains are implemented within the Continuous Delivery service and learn to develop and deploy a simple web application using these toolchains.
Prerequisites:
- IBM Cloud Code Engine: A Code Engine Project and an API Key. You can create these resources by using either the UI or the CLI. For more information about Code Engine Projects, see Code Engine Projects.
- Secrets Manager : With Secrets Manager, you can create, lease, and centrally manage secrets that are used in IBM Cloud services or your custom-built applications. Secrets are stored in a dedicated Secrets Manager instance, built on open source HashiCorp Vault
- Create a namespace on the Container Registry
- Provision the Continuous Delivery in the specified region and proceed with creating the instance.

This above diagram illustrates a CI/CD pipeline workflow integrated with Code Engine to deploy applications
CI/CD pipeline workflow integrated with Code Engine
- Issue Tracker → Developers begin by resolving tasks or defects.
- App Repo → The app repository is where code modifications are done.
- PR Pipeline → Pull Requests undergo review through testing and analysis.
- Code Risk Analyzer → Code Risk Analyser evaluates code for risks and quality issues.
- CI Pipeline (Continuous Integration Pipeline)→ Once validated, code is built, tested, and packaged.
- Code Engine → The final verified app is deployed to Code Engine.
Steps to Create an Open Toolchain and Deploy the Code Engine App:
Step 1: Create the Toolchain

- On the Welcome page, review the default toolchain settings. Ensure the toolchain name is unique within the same region and resource group in IBM Cloud.

Step 2: Configure the application and the Secret Manager.

- In the Application step, the recommended options for the application source code repo are displayed by default. To view all of the available options for the underlying Git integration, click Advanced Options. By default, the toolchain uses the default sample that clones the sample app as an IBM-hosted Git Repos and Issue Tracking repo.
-
Optional. The toolchain template provides a Sample Hello World Application app. If you want to link an existing Application repo for the toolchain, select Bring your own app and specify the URL for the repo. The toolchain supports linking only to existing Git Repos and Issue Tracking repos.
-
Here you can change the name of the app repo. The region of the repo remains the same as the region of the toolchain.
- IBM Secrets Manager securely stores and manages secrets like API keys, image signatures, and HashiCorp credentials, which are integral to your toolchain.
- If you have already created the Secrets Manager instance, the Toolchain will be automatically populated with preconfigured secrets. You don't need to manually select secrets from the vault integrations attached to the toolchain.

Step 3: Select your application build strategy and deployment type

Step 4: Configure the deployment target
Step 5: Complete the toolchain setup
- On the Summary page, click Create toolchain. Several steps run automatically to set up your toolchain.

Step 6: Set Up the Toolchain and discovering the pipelines
-
Continuous Integration Pipeline(CI-Pipeline): Runs Unit Tests, Code Coverage, Static Scans, CIS, and BOM checks when changes are merged into the master branch. It also builds and uploads artifacts to IBM Cloud Kubernetes Service and stores metadata in the Inventory repo.
-
Continuous Deployment Pipeline(CD-Pipeline): Deploys Code Engine component images built by the CI pipeline to a different project.
- Pull Request Pipeline(PR-Pipeline): Runs Unit Tests and Static Scans when changes are merged into any branch.
- On the Toolchain Overview page, initiate the Continuous Integration pipeline by selecting the card labeled Delivery Pipeline.

- On the Next Page, navigate to the section where you can trigger the
manual-run for the CI pipeline.

- During the run process, the application repository will remain in a pending state, progressing through each stage, until all stages of the CI pipeline successfully complete. Click the Logs tab, and scroll to the end of the log. You can check the repository associated with your application for updates.

- On the Toolchain Overview page,Now proceed with the continuous delivery/deployment pipelines(cd pipeline) . Then run pipeline to start the
cd-manual-run trigger.

- Once the Continuous Deployment pipeline run is successful, you can click on the pipeline run to review the completed steps.. Click the Parameters tab, Click the link to your deployed Code Engine app to view the running app.

- You can also verify this by navigating to the container project and reviewing the application.

Conclusion:
In this blog post, we looked at how to create an open toolchain with IBM Cloud Continuous Delivery and publish an app on Code Engine. The development process is streamlined by including automated pipelines for build, test, scan, and deployment, resulting in efficient and dependable application delivery. This solution takes advantage of serverless computing to enable scalable and smooth deployments.