DEV Community

Cover image for IBM Cloud Code Engine (serverless) Application setup with a private registry — Step by Step Guide
Alain Airom
Alain Airom

Posted on

IBM Cloud Code Engine (serverless) Application setup with a private registry — Step by Step Guide

The aim of the use case presented here is to provide a simplified step-by-step guide to deploy applications (any kind of application type eg. Batch, Job or Applications) from a private code repository (example here is using a private GitHub repo) to a private container image registry hosted on IBM Cloud.

This document assumes working with a private GitHub repository.

Create a Private Container Image Registry on IBM Cloud

The documentation: https://cloud.ibm.com/registry/start

Install, Set Up, and Log In

  ibmcloud plugin install container-registry -r 'IBM Cloud'
Enter fullscreen mode Exit fullscreen mode
  • Log in to your IBM Cloud account
  ibmcloud login -a https://cloud.ibm.com
Enter fullscreen mode Exit fullscreen mode

If you have a federated ID, use ibmcloud login --sso to log in to the IBM Cloud CLI.

ibmcloud login --sso
  • Ensure that you're targeting the correct IBM Cloud Container Registry region. Hereafter the region is set to Frankfurt
  ibmcloud cr region-set eu-central
  '''
  The region is set to 'eu-central', the registry is 'de.icr.io'.
Enter fullscreen mode Exit fullscreen mode
  • Choose a name for your first namespace, and create that namespace. Use this namespace for the rest of the Quick Start.
  ibmcloud cr namespace-add <my_namespace>
  '''
  ibmcloud cr namespace-add xxx_namespace
  Adding namespace 'xxx_namespace' in resource group 'default' for account XYZ's Account in registry de.icr.io...
Enter fullscreen mode Exit fullscreen mode

Image description
### Push the image to your private registry (Testing the working with your registry)

  • Log your local Docker daemon into the IBM Cloud Container Registry.
  ibmcloud cr login
Enter fullscreen mode Exit fullscreen mode
  • Pull a test image from Docker Hub
  docker pull hello-world
  '''
  Using default tag: latest
  c1ec31eb5944: Download complete
  d2c94e258dcb: Download complete
  docker.io/library/hello-world:latest
Enter fullscreen mode Exit fullscreen mode
  • Choose a repository and tag by which you can identify the image. Use the same repository and tag for the rest of this Quick Start
  docker tag hello-world de.icr.io/xxx_namespace/xxx_repository:my_tag
Enter fullscreen mode Exit fullscreen mode

Image description

  • Push the image
  docker push de.icr.io/xxx_namespace/xxx_repository:1
  '''
  docker push de.icr.io/xxx_namespace/xxx_repository:1                                                     
  The push refers to repository [de.icr.io/xxx_namespace/xxx_repository:1]
  1: digest: sha256:5c2d1c82f9ecc3c3f3b3a4a50f6db9d09cdddb301f3eff37ff2116aa3a65ae10 size: 861
Enter fullscreen mode Exit fullscreen mode
  • Verify that your image is in your private registry
  ibmcloud cr image-list
  '''
  Listing images...

  Repository                               Tag   Digest         Namespace       Created         Size     Security status
  de.icr.io/xxx_namespace/aam_repository   1     5c2d1c82f9ec   xxx_namespace   10 months ago   2.5 kB   -
Enter fullscreen mode Exit fullscreen mode

Image description

Create a Project in Code Engine

Image description

Image description

  • Select Projects in the left side menu, select the Location and Resource group, optionally set Tags and hit the Create button

Image description

  • Once the project is created, enter the project

Create an application from a private GitHub repository

Image description

Image description

  • Specify the build details and hit Next

Image description

  • You see the Registry server. You can either let Code Engine generate a secret for the registry or build your own secret (refer to IAM documentation on IBM Cloud). Choose the right Namespace for your application deployment and you can let Code Engine manage the Repository (image name). Hit the Done button to start building your application.

Image description

  • Once your application is deployed and running you can access it through the interface! You're done, congrats!!!

Image description

Links and helpers

Top comments (0)