Optional Lab 4: Use Code Engine to build a container image¶
In this optional lab we will build and push the web-app
container image to the IBM Cloud Registry. The IBM Cloud Registry has a free lite plan with limited resources of Storage (Gigabyte-Months):
- 0.5 GB free per month and pull traffic (Gigabytes)
- 5 GB free per month.
Please visit the IBM Cloud Registry catalog for the current pricing.
After the creation of the web-app
container image and when the image is saved in the IBM Cloud Registry, we can simply replace the Container image reference
for the web-app
application in Code Engine in a new configuration. The following image shows a new Container image reference
value us.icr.io/cns-code-engine/web-app-image:v1
inside a newly created configuration web-app-00004
.
Architecture¶
The following simplified architecture diagram show the dependencies of the Code Engine project
, the IBM Cloud Container Registry
, the Quay Container Registry
, the IBM Cloud Logging
, the ÌBM Cloud Monitoring
and the GitHub project
.
Steps¶
Step 1: Create an IBM Cloud Container image Namespace
Open the following link:¶
```sh
https://cloud.ibm.com/registry/namespaces
```
-
Select Location
Dallas
and pressCreate
-
Enter for Name
cns-code-engine
and pressCreate
-
Verify the created Namespace
Step 2: Start to create a Registry access
in your Code Engine project¶
-
Open
Registry access
in your Code Engine project and pressCreate
-
Enter and select following values:
- Registry source:
Custom
- Registry name:
ibm-container-registry
- Registry server:
us.icr.io
- As you see, we need an
IAM API Key
. So we leave this browser tab open and we create a new browser tab. Open the following link in the new browser tab
https://cloud.ibm.com/iam/apikeys
- Registry source:
-
Press
Create an IBM Cloud API key
-
Insert following value and select
Create
- Name:
code-engine IBM Cloud API key
- Name:
-
Copy
IBM Cloud API key
to clipboard -
Go back to the
Registry access
tab, insert the copiedIBM Cloud API key
and pressCreate
-
Verify the newly created
Registry access
Step 3: Start to create a Image build
in your Code Engine project
¶
-
Open
Image builds
in your Code Engine project and pressCreate
-
The
Specify build details
wizard appears, which contains three stepsSources
,Strategy
andOutput
. -
Insert the following values for
Sources
and pressNext
- Name:
web-app-image
- Code repo URL:
https://github.com/IBM/ce-cns
- Code repo access:
Public
- Branch name:
master
- Context directory:
./code/web-app
- Name:
-
Insert or select following values for
Strategy
and pressNext
- Strategy:
Dockerfile
- Dockerfile:
Dockerfile.os4-webapp
- Timeout:
10m
- Build resources:
Small (0.5 vCPU/ 2 GB)
- Strategy:
-
Insert or select the following values for
Output
and pressDone
- Registry server:
us.icr.io
- Registry access:
ibm-container-registry
- Namespace:
cns-code-engine
- Repository (image name):
web-app-image
- Tag:
v1
- Registry server:
Step 4: Now create the container image¶
-
Press
Submit build
-
The
Build run
dialog appears.Verify the
Output image
valueus.icr.io/cns-code-engine/web-app-image:v1
and pressSubmit build
again. -
Open the current
Build run
-
Open the current
Build run
and observe the progress -
Verify the created image
Congratulations, you have successfully completed this optional hands-on lab tasks for
Use Code Engine to build a container image
section of the workshop. Awesome