<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>9.9 Demo lab: show Docker alternatives on Application Migration and Modernization Techlab</title><link>/docs/additional/demo/</link><description>Recent content in 9.9 Demo lab: show Docker alternatives on Application Migration and Modernization Techlab</description><generator>Hugo</generator><language>en-us</language><atom:link href="/docs/additional/demo/index.xml" rel="self" type="application/rss+xml"/><item><title>9.9.1 Build a container image</title><link>/docs/additional/demo/build-container-image/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>/docs/additional/demo/build-container-image/</guid><description>&lt;div class="alert alert-primary" role="alert"&gt;


This is a demo lab because your WEB-IDE does not contain the needed tools. Ask the moderator for a demo or install the tools on your computer.

&lt;/div&gt;

&lt;h2 id="task-9911-build-a-container-image"&gt;Task 9.9.1.1: Build a container image&lt;/h2&gt;
&lt;p&gt;The build can be done using any container building tool that supports &lt;code&gt;Dockerfile&lt;/code&gt; builds.&lt;/p&gt;
&lt;p&gt;The sample application is an HTTP server written in the &lt;a href="https://golang.org/" target="_blank" rel="noopener"&gt;Go programming language&lt;/a&gt;
.&lt;/p&gt;
&lt;p&gt;The following files are needed inside your application repository:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="#image-build-instruction"&gt;Dockerfile&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="#sample-go-application"&gt;main.go&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="sample-go-application"&gt;Sample go application&lt;/h3&gt;
&lt;p&gt;This Go code defines an HTTP server listening on port 8080. It has to be placed in the &lt;code&gt;main.go&lt;/code&gt; file.&lt;/p&gt;</description></item><item><title>9.9.2 Deploy a container image</title><link>/docs/additional/demo/deploy-container-image/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>/docs/additional/demo/deploy-container-image/</guid><description>&lt;h2 id="task-9922-deploy-a-container-image"&gt;Task 9.9.2.2: Deploy a container image&lt;/h2&gt;
&lt;p&gt;As you know from other techlabs, an easy way to create applications in OpenShift is using &lt;a href="https://docs.openshift.com/container-platform/latest/cli_reference/openshift_cli/developer-cli-commands.html#new-app" target="_blank" rel="noopener"&gt;oc new-app&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;Let&amp;rsquo;s create an application for the go-hello-world image that we built before.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;oc new-app appuio/go-hello-world --as-deployment-config
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;div class="alert alert-primary" role="alert"&gt;


Since &lt;a href="https://docs.openshift.com/container-platform/4.5/release_notes/ocp-4-5-release-notes.html#ocp-4-5-developer-experience" target="_blank" rel="noopener"&gt;OpenShift 4.5&lt;/a&gt;
 &lt;code&gt;oc new-app&lt;/code&gt; creates a Deployment not a DeploymentConfig. We let it create a DeploymentConfig by adding the &lt;code&gt;--as-deployment-config&lt;/code&gt; flag.

&lt;/div&gt;

&lt;pre tabindex="0"&gt;&lt;code&gt;--&amp;gt; Found container image 5779c56 (11 days old) from for &amp;#34;appuio/go-hello-world:latest&amp;#34;

 * This image will be deployed in deployment config &amp;#34;go-hello-world&amp;#34;
 * Port 8080/tcp will be load balanced by service &amp;#34;go-hello-world&amp;#34;
 * Other containers can access this service through the hostname &amp;#34;go-hello-world&amp;#34;

--&amp;gt; Creating resources ...
 deploymentconfig.apps.openshift.io &amp;#34;go-hello-world&amp;#34; created
 service &amp;#34;go-hello-world&amp;#34; created
--&amp;gt; Success
 Application is not exposed. You can expose services to the outside world by executing one or more of the commands below:
 &amp;#39;oc expose svc/go-hello-world&amp;#39;
 Run &amp;#39;oc status&amp;#39; to view your app.
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;To access the application from outside OpenShift, a route is needed:&lt;/p&gt;</description></item><item><title>9.9.3 Docker Instructions</title><link>/docs/additional/demo/docker-instructions/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>/docs/additional/demo/docker-instructions/</guid><description>&lt;h2 id="9931-docker-instructions"&gt;9.9.3.1 Docker instructions&lt;/h2&gt;
&lt;p&gt;Building, testing and publishing of the container image using &lt;a href="https://www.docker.com/" target="_blank" rel="noopener"&gt;Docker&lt;/a&gt;
.&lt;/p&gt;
&lt;h3 id="image-build"&gt;Image build&lt;/h3&gt;
&lt;p&gt;Docker build command:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;docker build -t go-hello-world
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="image-test"&gt;Image test&lt;/h3&gt;
&lt;p&gt;Docker run command:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;docker run -p 8080:8080 -ti go-hello-world
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;It can be tested with a browser (&lt;a href="http://localhost:8080/world" target="_blank" rel="noopener"&gt;http://localhost:8080/world&lt;/a&gt;
) or using curl:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;curl localhost:8080/world
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="publish-image-to-docker-hub"&gt;Publish image to Docker Hub&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;docker login
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;docker tag go-hello-world:latest appuio/go-hello-world:latest
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;docker push appuio/go-hello-world:latest
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description></item></channel></rss>