Building a docker container image, upload it to IBM Cloud Container Registry, and deploy an application on cloud using a serverless technology called IBM Code Engine!
Clone the source code Build Docker image Deploy on Docker Tag and Push image to IBM Cloud Deploy on IBM Code Engine
#Docker Containers are isolated environments that package applications and their dependencies. Each container runs as an isolated process on the host operating system.
Docker is an open-source platform that enables developers to automate the deployment and management of applications inside lightweight, isolated containers.
IBM Cloud is a cloud computing platform and suite of cloud-based services offered by IBM. It provides a range of infrastructure, platform, and software services to support the development, deployment, and management of various types of applications and workloads in the cloud.
IBM Cloud Code Engine is a serverless compute platform provided by IBM Cloud. It allows developers to deploy and run containerized applications without the need to manage the underlying infrastructure. Abstracting away the complexities of server provisioning, scaling, and maintenance, enabling developers to focus on writing code and building applications.
#Step 1 Verify that docker CLI is installed. Of terminal and type
Command to Check:
docker --version
#Step 2 Verify that ibmcloud CLI is installed.
Again in terminal
Command to Check:
ibmcloud version
#Step 3 On the menu select Code Engine. The code engine setup panel appears. Click Create Project to begin.
#Step 4 The code engine environment takes a while to prepare. You will see the progress status is indicated in the setup panel.
#Step 5 Once the code engine set up is complete, you can see that it is active. Click Code Engine CLI to begin the pre-configured CLI in the terminal as shown below.
#Step 6 You will observe that the pre-configured CLI startup and the home directory are set to the current directory. As a part of the pre-configuration, the project has been set up, and Kubeconfig is set up. The details are shown on the terminal as follows.
#Step 6
Open a terminal window by using the menu in the editor: Terminal > New Terminal.
At this point Enter Git Commands to clone your existing repo. or import your already developed application. After sucessfully Importing your application follow below steps
Let’/s start modernising our application. The first step towards it is to containerise it using Docker.
tasks:
Paste the following content in "Open Dockerfile in IDE"
Use the below as Dockerfile content.
FROM nginx COPY favicon.ico /usr/share/nginx/html/favicon.ico
COPY index.html /usr/share/nginx/html/index.html
COPY script.js /usr/share/nginx/html/script.js
COPY style.css /usr/share/nginx/html/style.css
COPY data.json /usr/share/nginx/html/data.json
And it should look like below:
Following Code
docker build -t Your Project Name .
Following Code
docker images .
Let’s start with launching Code Engine CLI.Following Code
docker run -it -d -p 8080:80 Your App Name
Type
docker push us.icr.io/${SN_ICR_NAMESPACE}/Your-App-Name
Type
ibmcloud ce application create --Your-App --image us.icr.io/${SN_ICR_NAMESPACE}/Your-App --registry-secret icr-secret --port 80
Take Cloud URL from the output; which looks something like: https://Your_app.somerandomalphanumeric.us-south.codeengine.appdomain.cloud and open in your browser.
You have completed the deployment and learned how to deploy and host a standard application in Docker and on IBM Cloud.
Shudhanshu Ranjan