An Interest In:
Web News this Week
- March 27, 2024
- March 26, 2024
- March 25, 2024
- March 24, 2024
- March 23, 2024
- March 22, 2024
- March 21, 2024
Using Containers With Bluemix DevOps Services
Introduction
This tutorial will demonstrate some of the integrated capabilities found in IBM Bluemix and IBM Bluemix DevOps Services (IDS).
Bluemix now includes a new beta service to host Docker container-based applications. This service allows users to build and deploy their Docker applications completely on the IBM cloud.
Today's tutorialwill highlight an agile process to write, build, and deploy Docker applications using DevOps best practices for continuous delivery using an automated pipeline to deliver new application versions faster.
I'll also demonstrate a new web-based way to code that does not require the installation of any development environment, or for that matter, any application besides a browser.
In order to walk through our guide, you will need a Bluemix account that has been previously linked with IDS. I'll show you how.
Build and Deploy an Application Using the IBM Container Service
Log in to Bluemix
1. Using your browser, go to the Bluemix website.
2a. If you don't have an account, please click SIGN UP to register.
Then, check your email for the confirmation link and complete your registration. Your username should be the email address you used during registration.
2b. Otherwise, press the LOG IN button located at the top right-hand corner of the page.
3. In the following page, provide the email and password and press the Sign in button.
4. In the Dashboard page, you should notice that you do not have any Applications created yet.
Log in to IDS
1. Using your browser, open another tab and go to the IDS website.
2. Press the LOG IN button located at the top right-hand corner of the page.
3. In the following page, press the Sign In button.
4. In the IDS landing page, press the EXPLOREtab at the top of the page.
5. In the Explore page, type “ibluemx” in the search bar and press the Enterkey.
6. A list of projects will be displayed; select “container-devops”.
Fork the Project
1. Press FORK PROJECT to create a personal copy of the project to work with.
2. In the Fork Project window, provide a name for your project and make a note of it.
Note: The deployed application will need to have a unique name, so it would be a good idea to name the project something like “container-devops-<username>”, where <username> is your account's username.
And check the Make it private (not public) checkbox, leave all other items as set, and press the CREATEbutton.
Inspect the Project Code
1. On the new project page, you should receive the following message “Congratulations! You have successfully created your new project.”
Let's look at the project source code by first pressing the EDIT CODEbutton.
2. In the left-hand tree view, select the file named “Dockerfile”. The file contents will display in the main editor window.
This will give you an opportunity to see the instructions that will be used to create our Docker container.
3. In the left-hand tree view, select the “app. js” file. The file contents will display in the main editor window.
This will give you an opportunity to see the code for the simple application that will run inside the Docker container.
Note: On line 22, the application will output the following: “Hello Docker Pipeline! version 1.0”.
Configure the DevOps Pipeline: Build Stage
1. Click on the BUILD & DEPLOY button.
2. On the Build & Deploy Pipeline page, press the + ADD STAGElink.
3. In the reloaded page, rename the stage name from the default “MyStage” to “Build” and press the JOBStab in the window.
4. In the JOBStab, click on ADD JOBand select Build.
5. Set the Builder Typeto IBM Container Service on Bluemix, set the Image Nameto ibluenodeand press the SAVEbutton to continue.
Configure the DevOps Pipeline: Deploy Stage
1. Back on the Build & Deploy Pipeline page, press the + ADD STAGElink.
2. In the reloaded page, rename the stage name from the default “MyStage” to “Deploy” and press the JOBStab in the window.
4. In the JOBStab, click on ADD JOBand select Deploy.
5. On the Stage Configurationpage, set the Deployer Typeto IBM Container Service on Bluemix.
Press the SAVE button to continue.
Run an Initial Build and Deploy
1. To test the pipeline, we will run an initial build. Back on the Pipeline: All Stagespage, press on the play arrow (which is a right-hand pointing triangle) at the top of the Buildstage.
Note: At any time, you can click on the “View logs and history” link to see detailed messages.
2. The pipeline will automatically progress from Build to Deploy once the Build stage is complete.
Once the Deploy stage is complete, you will see the resulting container under the LAST EXECUTION RESULTin the Deploy stage box.
Click on the IP address located under the LAST EXECUTION RESULTin the Deploy stage box.
3. This will open a new browser window and show the result of the newly deployed web application, which should read:
Hello Docker Pipeline! Version 1.0
Change the Application Code
1. Press the EDIT CODEbutton to return to the editor.
2. Edit the “app. js” file and set the value of “res. send” to “Hello Docker Pipeline! version 2.0”, and save the changes by pressingControl-S (Windows), Command-S (Mac) or pressing File > Save (tablets) in the editor toolbar (not in the browser window).
Commit the Code to the Git Repository
1. Press the Git repository button at the left of the screen (under the pencil icon).
2. In the Working Directory Changeswindow, press the Select Allcheckbox, provide some commit text (in my case I added “Increased the version displayed”), and press the Commitbutton.
3. Once the changes have been committed, you need to press the SYNCbutton to synchronize with the master branch.
Run a Build and Deploy
1. Press the BUILD & DEPLOYbutton to return to the Pipeline: All Stagespage.
2. You will see that the build has automatically started running based on the synchronization of the change to the repository.
Note: At any time you can click on the “View logs and history” link to see detailed messages.
3. The pipeline will progress from Build to Deploy once the Build stage is complete.
Once the Deploy stage is complete, you will see the resulting container under the LAST EXECUTION RESULTheader in the Deploy stage box.
Click on the IP address located under the LAST EXECUTION RESULTin the Deploy stage box.
4. This will open a new browser window and show the result of the newly redeployed web application which should read:
Hello Docker Pipeline! Version 2.0
Continue to Iterate on Your Application
You can now extend the application by modifying the app. js file in a new way to render different content, or you can choose to use a completely different Dockerfile, such as one found onContainers and Cloud Foundry Hands-On Labs on GitHub,e.g. PCF-Demo.
Related Links
Original Link:
TutsPlus - Code
Tuts+ is a site aimed at web developers and designers offering tutorials and articles on technologies, skills and techniques to improve how you design and build websites.More About this Source Visit TutsPlus - Code