<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Chris Bailey on Medium]]></title>
        <description><![CDATA[Stories by Chris Bailey on Medium]]></description>
        <link>https://medium.com/@chris-bailey?source=rss-b6e25c635654------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*3Rh32N2AAJR-ErDFfYXP4w.png</url>
            <title>Stories by Chris Bailey on Medium</title>
            <link>https://medium.com/@chris-bailey?source=rss-b6e25c635654------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 22:08:30 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@chris-bailey/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Server-Swift Swift: Develop in Xcode, Continuously verify in Docker]]></title>
            <link>https://medium.com/appsody/server-side-swift-a77bff1d8f1?source=rss-b6e25c635654------2</link>
            <guid isPermaLink="false">https://medium.com/p/a77bff1d8f1</guid>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[vapor]]></category>
            <category><![CDATA[vaporswift]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[kitura]]></category>
            <dc:creator><![CDATA[Chris Bailey]]></dc:creator>
            <pubDate>Sun, 01 Sep 2019 16:07:21 GMT</pubDate>
            <atom:updated>2019-09-02T02:23:25.288Z</atom:updated>
            <content:encoded><![CDATA[<h3>Server-Side Swift: Develop in Xcode, Continuously verify in Docker</h3><p>Due to the availability of the Swift Language Server Protocol (LSP) library, there are now more IDEs that you can use to develop server-side Swift applications, including using VSCode on Linux. Undoubtedly though, the vast majority of development is still done using Xcode on macOS.</p><p>Whilst this is great in terms of support for the Swift language — and with the support for Swift Package Manager added in Xcode 11, for package management — there is still the challenge of ensuring that the APIs, frameworks and packages that you are using on macOS are supported and work in the same way on Linux.</p><p>The new support for Swift in the Appsody cloud-native development tools helps to solve that challenge, by enabling you to continuously run and test your code in a Docker container as you develop in Xcode.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DELjr4SUVq7dkE3v0v-hrQ.png" /><figcaption>Develop in Xcode, Verify in Docker, Deploy to Kubernetes</figcaption></figure><p>This means that, as you develop in Xcode (or any other IDE), your code is mirrored into a Docker container which rebuilds every time you save your code changes — meaning you can immediately see if you code changes fail or have different behaviour on Linux.</p><p>Below you’ll see how to enable your project and run it in the Appsody environment in parallel to working in Xcode.</p><h3>Pre-requisites</h3><p>In order to follow this tutorial, you’ll need to install the Appsody CLI, which also requires you to have Docker installed, along with having your Swift application.</p><p><strong>Install Docker</strong></p><p>It is recommended that you do this using <a href="https://docs.docker.com/docker-for-mac/install/">Docker for Desktop for Mac</a>, which is available as a download from Docker Hub.</p><p><strong>Install the Appsody CLI</strong><br>The Appsody CLI can be installed by following the <a href="https://appsody.dev/docs/getting-started/installation">Installing Appsody</a> guide. On macOS is is done using Homebrew:</p><pre>brew install appsody/appsody/appsody</pre><p><strong>Create a sample application</strong><br>Additionally, you’ll need a server-side Swift application. You can either use one you already have, or create a sample application using one of the two approaches below:</p><p><strong>Option 1: Create a sample application using Kitura<br></strong>You can create a sample application using the Kitura macOS app using the “<a href="https://www.kitura.io/docs/getting-started/create-server-app.html">Create a server with the Kitura macOS app</a>” guide, or using the Kitura CLI by following the “<a href="https://www.kitura.io/docs/getting-started/create-server-cli.html">Create a server with the Kitura CLI</a>” guide. The steps below show how to use the CLI:</p><ol><li>Install the Kitura CLI using Homebrew:</li></ol><pre>brew install ibm-swift/kitura/kitura</pre><p>2. Create a directory for your Swift project</p><pre>mkdir ~/swiftapp<br>cd ~/swiftapp</pre><p>3. Create a Kitura application</p><pre>kitura init</pre><p><strong>Option 2: Create a sample application using Vapor</strong></p><p>You can create a sample application using the Vapor CLI by following the “Install on macOS” guide to install the CLI, followed by the “Hello World” guide to create you application. Those steps are summarized below:</p><ol><li>Install the Vapor CLI using Homebrew:</li></ol><pre>brew install vapor/tap/vapor</pre><p>2. Make sure you are in your home directory</p><pre>cd ~</pre><p>3. Create a Vapor application</p><pre>vapor new swiftapp<br>cd swiftapp</pre><p>4. Create an Xcode Project for your app (only required for Xcode 10 and before)</p><pre>swift package generate-xcodeproj</pre><h3>Enabling your application to work with Appsody</h3><p>New Appsody based applications are created using appsody init &lt;stack&gt; &lt;template&gt;, where the names of the stack and the template are from those listed when running appsody list. This both downloads the most recent copy of the Appsody Stack — essentially the development and build environment for that language) — and populates the project directory with a template that provides a basic project structure.</p><p>In order to enable an existing application with a stack, the same steps can be followed, but using a template name of none with theappsody init command.</p><p>1. Enable the Swift Application:</p><pre>appsody init swift none</pre><p>This will print output similar to the following to the console:</p><pre>Running appsody init...</pre><pre>Downloading swift template project from <a href="https://github.com/appsody/stacks/releases/download/swift-v0.1.4/incubator.swift.templates.simple.tar.gz">https://github.com/appsody/stacks/releases/download/swift-v0.1.4/incubator.swift.templates.simple.tar.gz</a><br>Download complete. Extracting files from swift.tar.gz<br>Setting up the development environment<br>Running command: docker[pull appsody/swift:0.1]<br>Running command: docker[run --rm --entrypoint /bin/bash appsody/swift:0.1 -c find /project -type f -name .appsody-init.sh]<br>Successfully initialized Appsody project</pre><p>As well as downloading the latest version of the Appsody Stack (in this case version 0.1), this has added a <strong>.appsody-config.yaml</strong> file to the project, which configures the versions of the Stack that the project will use.</p><p>At this point, your application has been enabled, which means you can now run , test and debug your application in a continuous containerized environment provided by the Appsody Stack, to build it into a optimized container image, and to deploy it to Kubernetes.</p><h3>Developing your application with Appsody</h3><p>Now that your application has been enabled, you can use the run, test and debugcommands to the Appsody CLI to work with your application in a continuous containerized environment provided by the Appsody Stack.</p><p>Appsody’s run mode provides a continuous development environment, where changes that are saved to your project cause your application to be restarted.</p><ol><li>First open your project in Xcode so that you can make changes to your project:</li></ol><ul><li>Xcode 10 and earlier:</li></ul><pre>cd ~/swiftapp<br>xed .</pre><ul><li>Xcode 11 and beyond:</li></ul><pre>cd ~/swiftapp<br>open Package.swift</pre><p>2. Next, start the continuous run environment, by using the Appsody CLI in the terminal window:</p><pre>appsody run</pre><blockquote>This will build and run your application in a Docker container. The first run may take a couple of minutes as it downloads and builds your application for the first time, but subsequent runs will cache that data.</blockquote><p>3. Finally, open your browser to see your Swift application running inside the Docker container: <a href="http://localhost:8080/">http://localhost:8080</a></p><p>If you are running the Kitura sample app, you should see the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W1eGFPxDAUic8AdF40HuyQ.png" /><figcaption>“Your Kitura server is up and running!” — Success from Kitura App</figcaption></figure><p>However if you are running Vapor, you should receive an error with the web page failing to load. This is because Vapor apps only accept requests from localhost by default — and the Docker container does not see your host machine (ie, your macbook) as localhost — so we need to enable remote connections.</p><p>You can do that by adding the following into Sources/App/app.swift in Xcode:</p><pre><strong>let</strong> serverConfig = NIOServerConfig.default(hostname: &quot;0.0.0.0&quot;)<br>services.register(serverConfig)</pre><p>As appsody run provides a continuous development environment, any code changes you make will cause an automatic restart of the application — just go back to your browser and see if you can now connect to your app. You should now see:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BfUPibQuJTrEjX5rVoll0A.png" /><figcaption>“It works!” — Success from Vapor App in Appsody</figcaption></figure><p>4. Make a code change to your project that will be reflected in the browser. <br>Any code changes you now make should be immediately reflected. If you’re using Vapor, you’ve already seen that in order to enable requests from non-localhost addresses to be handled.</p><p>For Kitura, a simple code change is to remove the Health Route.</p><blockquote>By default, Kitura provides a /health route that responds with the status of the Kitura server. This is provided because many clouds and cloud technologies — like Kubernetes — can use this to determine whether the application needs to be automatically restarted.</blockquote><p>To do that, edit Sources/Application/application.swift to remove the following line:</p><pre>initializeHealthRoutes(app: <strong>self</strong>)</pre><p>Save the file, and open <a href="http://localhost:8080/health">http://localhost:8080/health</a> to see that the route it no longer present!</p><h3>Working with your application in Test mode</h3><p>Appsody’s test mode makes it possible to run any tests that your application has inside the containerized environment.</p><p>Run the tests using the Appsody test mode:</p><pre>appsody test</pre><p>This will respond with the output of your tests being run:</p><pre>[Container] Test Suite &#39;All tests&#39; started at 2019-09-01 11:58:12.127<br>[Container] Test Suite &#39;debug.xctest&#39; started at 2019-09-01 11:58:12.171<br>[Container] Test Suite &#39;RouteTests&#39; started at 2019-09-01 11:58:12.172<br>[Container] Test Case &#39;RouteTests.testGetStatic&#39; started at 2019-09-01 11:58:12.172<br>[Container] ------------------------------<br>[Container] ------------New Test----------<br>[Container] ------------------------------<br>...<br>[Container] Test Case &#39;RouteTests.testGetStatic&#39; passed (0.21 seconds)<br>[Container] Test Suite &#39;RouteTests&#39; passed at 2019-09-01 11:58:12.382<br>[Container]   Executed 1 test, with 0 failures (0 unexpected) in 0.21 (0.21) seconds<br>[Container] Test Suite &#39;debug.xctest&#39; passed at 2019-09-01 11:58:12.383<br>[Container]   Executed 1 test, with 0 failures (0 unexpected) in 0.21 (0.21) seconds<br>[Container] Test Suite &#39;All tests&#39; passed at 2019-09-01 11:58:12.383<br>[Container]   Executed 1 test, with 0 failures (0 unexpected) in 0.21 (0.21) seconds</pre><p>Note that, unlike run anddebug, test executes a single run of the tests rather than a continuous container.</p><h3>Building your application with Appsody</h3><p>Once you have reached a point that you would like to build a deployable container image for your application, you can do that using appsody build. This creates a production-optimized image that is built using the regular <a href="https://hub.docker.com/_/swift">“swift” Official Docker image</a> from the Swift community and then rebased on the communities “slim” image. The “slim” image is both significantly smaller that the regular image, making it easier and faster to deploy to a cloud, and more secure because it does not include the Swift compiler — it only contains enough to run your application.</p><p>The steps below show how to build the container image for your application, and then run it locally using Docker:</p><p>1. Build the container image for your application:</p><pre>appsody build</pre><p>This builds a container image for your application, using the name of your project as the “tag” (which is the name of the folder in which is resides). The final line of the output gives the name of the image:</p><pre>Built docker image swiftapp</pre><blockquote>To see the size of your built image, you can use docker images. This shows that the built image is 315MB. If this was built with the full Swift image it would have been 1.47 GB!</blockquote><p>2. Run the container image using Docker:</p><pre>docker run — rm -p 8080:8080 -i -t swiftapp</pre><p>This runs your container image, using the-p option to map port 8080 from the container to port 8080 on your machine, the -i option to run interactively (so you can use <strong>Ctrl-C</strong> to stop the container), the --rm option to remove the container when its stopped, and the -t option to run the container image with our “tag” of swiftapp.</p><p>3. Open your browser to see the application running: <a href="http://localhost:8080/">http://localhost:8080</a></p><p>4. Finally, stop the container by using <strong>Ctrl-C</strong> in the terminal window where docker run is executing.</p><p>You now have a cloud packaged available in a container image that is ready to be deployed to any cloud that supports container images.</p><p>If you have access to a Kubernetes cluster, you can also very easily deploy the built application using the appsody deploy command.</p><h3>Next Steps</h3><p>This article covered how to take develop your server-side Swift application and develop it with the benefit of a continuous Linux environment running in a Docker container locally on your MacBook using Appsody.</p><p>Appsody provides similar experiences for many other languages and frameworks including Java, Node.js and Python, as well as an easy mechanism to deploy and manage your application in Kuberentes.</p><p>For more information on <a href="https://appsody.dev/">Appsody</a>, join us on <a href="http://appsody-slack.eu-gb.mybluemix.net/">Slack</a>, follow us on <a href="https://twitter.com/appsodydev">Twitter</a> and star us on <a href="https://github.com/appsody">GitHub</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a77bff1d8f1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/appsody/server-side-swift-a77bff1d8f1">Server-Swift Swift: Develop in Xcode, Continuously verify in Docker</a> was originally published in <a href="https://medium.com/appsody">Appsody</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cloud Functions for Node.js using Express.js (Connect) APIs]]></title>
            <link>https://medium.com/appsody/nodes-functions-839a70289b82?source=rss-b6e25c635654------2</link>
            <guid isPermaLink="false">https://medium.com/p/839a70289b82</guid>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[functions-as-a-service]]></category>
            <category><![CDATA[expressjs]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Chris Bailey]]></dc:creator>
            <pubDate>Mon, 12 Aug 2019 09:54:06 GMT</pubDate>
            <atom:updated>2019-08-12T17:09:14.252Z</atom:updated>
            <content:encoded><![CDATA[<p>According to a number of surveys that look at what Cloud Functions (eg. AWS Lambda, Azure Functions, Google Cloud Functions) are being used for, the number one use case is REST APIs.</p><p>The <a href="https://thenewstack.io/ebooks/serverless/guide-to-serverless-technologies/">2018 Serverless Survey</a> from <a href="https://thenewstack.io/">The New Stack</a> showed that 73% of respondents were building “HTTP REST APIs and web applications”:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ym1WAlq_HpekAMWkE5NahA.png" /><figcaption>The New Stack Serverless Survey 2018: 73% of respondents building REST APIs</figcaption></figure><p>Whilst the use of Cloud Functions provides a number of advantages, including being able to rapidly build and deploy code to clouds without having to deal with building, deploying, configuring and scaling servers, one of its challenges is that the APIs that you have to code to lack the domain specific focus and rich library ecosystem that you get from web and microservice frameworks.</p><p>Below is an example of an <a href="https://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-handler.html">AWS Lambda Function Handler in Node.js</a>:</p><pre>exports.handler = async function(event, context) {<br>  console.log(“EVENT: \n” + JSON.stringify(event, null, 2))<br>  return context.logStreamName<br>}</pre><p>This calls the user provided handler function with two parameters:</p><ul><li>event which contain field and data from the invoker, which is dependent on on how the function was invoked.</li><li>context which which additional information about the invocation, function, and execution environment.</li></ul><p>In the case of a handler function invoked by a HTTP REST request, the event parameter object contains the following (taken from the <a href="https://docs.aws.amazon.com/lambda/latest/dg/lambda-services.html">AWS Lambda Docs</a>):</p><pre>{     <br>  &quot;requestContext&quot;: {<br>    &quot;elb&quot;: {<br>      &quot;targetGroupArn&quot;: &quot;arn:aws:elasticloadbalancing:us-east-2:123456789012:targetgroup/lambda-279XGJDqGZ5rsrHC2Fjr/49e9d65c45c6791a&quot;<br>    }<br>  },<br>  &quot;httpMethod&quot;: &quot;GET&quot;,<br>  &quot;path&quot;: &quot;/lambda&quot;,<br>  &quot;queryStringParameters&quot;: {<br>    &quot;query&quot;: &quot;1234ABCD&quot;     <br>  },<br>  &quot;headers&quot;: {<br>    &quot;accept&quot;: &quot;text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8&quot;,<br>    &quot;accept-encoding&quot;: &quot;gzip&quot;,<br>    &quot;accept-language&quot;: &quot;en-US,en;q=0.9&quot;,<br>    &quot;connection&quot;: &quot;keep-alive&quot;,<br>    &quot;host&quot;: &quot;lambda-alb-123578498.us-east-2.elb.amazonaws.com&quot;,<br>    &quot;upgrade-insecure-requests&quot;: &quot;1&quot;,<br>    &quot;user-agent&quot;: &quot;Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36&quot;,<br>    &quot;x-amzn-trace-id&quot;: &quot;Root=1-5c536348-3d683b8b04734faae651f476&quot;,<br>    &quot;x-forwarded-for&quot;: &quot;72.12.164.125&quot;,<br>    &quot;x-forwarded-port&quot;: &quot;80&quot;,<br>    &quot;x-forwarded-proto&quot;: &quot;http&quot;,<br>    &quot;x-imforwards&quot;: &quot;20&quot;<br>  },<br>  &quot;body&quot;: &quot;&quot;,<br>  &quot;isBase64Encoded&quot;: false<br>}</pre><p>Whilst this provides all of the data you might need from the HTTP request, there are no parsers, data validators or other helper APIs provided for working with the request. Additionally, there are no APIs provided to facilitate you to build a valid HTTP response for the request.</p><p>By contrast, when you work with web and microservice frameworks for Node.js, such as Express.js, you both get access to those domain specific data types and APIs for working with requests and responses, and access to a rich module system that work with them: there are currently <a href="https://www.npmjs.com/package/connect?activeTab=dependents">2,167 modules</a> that depend on the “Connect” request handler and middleware format used by Express.js:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X0g4A0EW6AI7c6ES1QINEA.png" /></figure><p>Of course, this is because of a trade-off. When writing code using Cloud Functions you have the benefit of flexibility — the handler function API and datatypes are “generic” because you are able to register your function to work with any type of invoker — whether that’s a HTTP REST request, or something else entirely.</p><p>However if you are specifically building a REST API, wouldn’t it be great if you had access to all of the power and domain specific capabilities that you get from those domain specific frameworks?</p><h3>Node.js Functions with Appsody</h3><p><a href="https://appsody.dev/">Appsody</a>, which provides development tools for creating cloud packaged, cloud native and cloud functions based applications, has recently added an experimentalnodejs-function stack, which makes it possible to do function-style development using the “Connect” APIs used by Express.js.</p><p>When combined with Appsody’s ability to build best-practise container images and then deploy in a serverless fashion using <a href="https://knative.dev/">Knative</a>, this means you can build and deploy serverless Cloud Function, using domain specific APIs and libraries for building REST APIs.</p><h4>Getting Started</h4><p>To get started, you first need to <a href="https://appsody.dev/docs/getting-started/installation">install the “appsody” command line tool</a> (CLI) using the instructions provided.</p><p>Note that you need at least version 0.3.0 of the CLI:</p><pre>$ appsody version<br>appsody 0.3.0</pre><p>Next, you need to configure the Appsody CLI to additionally use the “experimental” repository using appsody repo add:</p><pre>appsody repo add experimental https://github.com/appsody/stacks/releases/latest/download/experimental-index.yaml</pre><p>This means that using appsody list will now show stacks from both the default “appsodyhub” repo and from the repo of “experimental” stacks:</p><pre>REPO         ID                VERSION DESCRIPTION<br>appsodyhub   swift             0.1.0   Runtime for Swift applications<br>appsodyhub   java-microprofile 0.2.4   Eclipse MicroProfile using OpenJ9 and Maven<br>appsodyhub   java-spring-boot2 0.3.2   Spring Boot using OpenJ9 and Maven<br>appsodyhub   nodejs-express    0.2.2   Express web framework for Node.js<br>appsodyhub   nodejs            0.2.2   Runtime for Node.js applications<br>experimental nodejs-functions  0.1.0   Serverless runtime for Node.js functions<br>experimental quarkus           0.1.0   Quarkus runtime for running Java applications</pre><p>Now create a new directory for your Node.js Functions project:</p><pre>mkdir function<br>cd function</pre><p>Finally, create your new Node.js Functions project:</p><pre>appsody init experimental/nodejs-functions</pre><p>You now have a skeleton project that you can use to develop, test, debug, build and deploy your functions using the Express.js APIs.</p><h4>Exploring the project</h4><p>The skeleton project provides the following files:</p><pre>./.vscode/launch.json<br>./.vscode/tasks.json<br>./.appsody-config.yaml<br>./package.json<br>./function.js</pre><p>The purposes of those files are as follows:</p><ul><li>.vscode/launch.json provides a VSCode configuration for attaching a debugger to the functions project.</li><li>.vscode/tasks.json provides VSCode configuration so that the Appsody CLI commands can easily run as VSCode Tasks.</li><li>.appsody-config.yaml provides control over which semantic version(s) of the nodejs-functions stack project works with.</li><li>package.json the standard file for describing Node.js project and their dependencies.</li><li>function.js an example Node.js Function</li></ul><p>Below is the function.js file in detail, which provides a simple example that responses to GET requests on / with Hello from Appsody!:</p><pre>module.exports.url = &#39;/&#39;<br>module.exports.get = function(req, res, next) {<br>  res.send(&#39;Hello from Appsody!&#39;)<br>}</pre><p>Node.js Functions supports the use of multiple functions, and has the following requirements:</p><ul><li>Each function must be defined in its own .js file</li><li>Each function file must export aurl field, which states the URL path that it responds on.</li><li>Each function file must export a Express.js (Connect) function handler, using the HTTP verb it reponds to as the export name.</li></ul><p>Beyond those requirements, you can develop the Node.js Functions as you would for any Node.js app, including registering additional module dependencies in the package.json file and then requiring those into your functions.</p><h4>Running, Testing and Debugging the project</h4><p>Now that you have created the project, you can utilize the iterative, containerized development environments that Appsody provides to develop your application.</p><p>First, see the functions project running by opening your project in VSCode and selecting <em>Terminal</em> &gt; <em>Run Task…</em> &gt; <em>Appsody: run</em> or by using appsody run in the Terminal or Console:</p><pre>appsody run </pre><p>This creates a containerized iterative development, and exposes your Node.js Funtions project to HTTP requests.</p><p>Open your browser to: <a href="http://localhost:3000/">http://localhost:3000</a></p><p>This will display the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1012/1*iRKizz8I0wsMUmV6T-lw8Q.png" /><figcaption>The Node.js Functions Project running on localhost:3000</figcaption></figure><p>Without stopping appsody run, you can now make changes to your project and see those changes immediate reflected.</p><p>Rather than showing this by editing the existing function, create a new file called hello.js. In the new file, add the following code:</p><pre>module.exports.url = &#39;/hello/:id&#39;<br>module.exports.get = function(req, res, next) {<br>  var id = req.params.id<br>  res.send(&#39;Hello &#39; + id + &#39; from Appsody!&#39;)<br>}</pre><p>This is standard Express.js code, that takes a URL parameter which is calls id, and echo’s that back inside the Hello from Appsody! message. Don’t forget to save the file!</p><p>Open your browser to: <a href="http://localhost:3000/Jane">http://localhost:3000/hello/Jane</a></p><p>This will display the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B7_cB5hdrOJySemuoUjAaA.png" /><figcaption>Node.js Functions project on localhost:3000/hello/Jane</figcaption></figure><p>This has automatically detected the additional function and added it to the iterative development environment.</p><p>Just like the Appsody Stacks for Express.js, the running application also has a number of built-in cloud native capabilities, such as:</p><ul><li>Health Checks: <a href="http://localhost:3000/health">http://localhost:3000/health</a></li><li>Prometheus Metrics: <a href="http://localhost:3000/metrics">http://localhost:3000/metrics</a></li><li>Performance Dashboard: <a href="http://localhost:3000/appmetrics-dash/">http://localhost:3000/appmetrics-dash/</a></li></ul><p>You can also use the other Appsody CLI commands to test, debug, build and deploy your functions project.</p><h3>Next Steps</h3><p>This article covered how to build Node.js Functions using the nodejs-express Appsody Stack which automatically provides the application with cloud-native capabilities such as liveness and readiness checks, along with metrics and observability.</p><p>For can read more about debugging the the performance dashboard in “<a href="https://medium.com/appsody/nodes-cloud-packaged-fe60e29b699d">Package your Node.js app for Cloud with Appsody</a>”, and more about the metrics capabilities in “<a href="https://medium.com/appsody/nodejs-express-enablement-f6fc2609bc00">Make your Express.js app Cloud-Native with Appsody</a>”.</p><p>For more information on <a href="https://appsody.dev/">Appsody</a>, join us on <a href="http://appsody-slack.eu-gb.mybluemix.net/">Slack</a>, follow us on <a href="https://twitter.com/appsodydev">Twitter</a> and star us on <a href="https://github.com/appsody">GitHub</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=839a70289b82" width="1" height="1" alt=""><hr><p><a href="https://medium.com/appsody/nodes-functions-839a70289b82">Cloud Functions for Node.js using Express.js (Connect) APIs</a> was originally published in <a href="https://medium.com/appsody">Appsody</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Make your Express.js app Cloud-Native with Appsody]]></title>
            <link>https://medium.com/appsody/nodejs-express-enablement-f6fc2609bc00?source=rss-b6e25c635654------2</link>
            <guid isPermaLink="false">https://medium.com/p/f6fc2609bc00</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[cloud-native]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[expressjs]]></category>
            <dc:creator><![CDATA[Chris Bailey]]></dc:creator>
            <pubDate>Mon, 15 Jul 2019 14:45:44 GMT</pubDate>
            <atom:updated>2019-07-16T12:18:16.440Z</atom:updated>
            <content:encoded><![CDATA[<p>In the previous article: “<a href="https://medium.com/appsody/nodejs-express-cloud-native-70022e7d5371">Build a new Cloud Native Express.js app with Appsody</a>”, you learned how to use <a href="https://appsody.dev/">Appsody</a> to build an Express.js app that inherits a set of cloud-native capabilities from the Appsody Stack.</p><p>In this article, you’ll see how to take an existing Express.js app, and make it cloud-native by enabling it to work with the same nodejs-expressAppsody Stack.</p><h3>Pre-requisites</h3><p>In order to follow this tutorial, you’ll need to install the Apposdy CLI, which also requires you to have Docker installed, along with the Express.js application you want to make cloud-native with Appsody.</p><h4>Install the Appsody CLI</h4><p>Before getting started, you’ll need to install the Appsody CLI.</p><p>1. Follow the <a href="https://appsody.dev/docs/getting-started/installation">Installing Appsody</a> guide to install the CLI for your platform.</p><h4>Obtain an existing Express.js application</h4><p>If you don’t have an existing Express.js application that you want to use, the following steps enable you to create one using the <a href="http://expressjs.com/en/starter/generator.html">Express.js Application Generator</a>. The examples in the article will assume you are using this.</p><p>1. Install the Express.js Application Generator:</p><pre>npm install -g express-generator</pre><p>2. Create a directory for your application:</p><pre>mkdir expressjs-app<br>cd expressjs-app</pre><p>3. Run the Express Application Generator to build a sample application:</p><pre>express</pre><h3>Enabling your Express.js application with the `nodejs-express` Appsody Stack</h3><p>New Appsody based applications are created using appsody init &lt;stack&gt;, where the name of the stack is one of those listed when running appsody list. This both downloads the most recent copy of the Appsody Stack, and populates the project directory with a template that provides a basic project structure.</p><p>In order to enable an existing application with a stack, the same steps can be followed, but using the --no-template option to appsody init as a project structure is not required.</p><p>1. Enable the Express.js Application:</p><pre>appsody init nodejs-express --no-template</pre><p>This will print output similar to the following to the console:</p><pre>Running appsody init…<br>Downloading nodejs-express template project from <a href="https://github.com/appsody/stacks/releases/download/nodejs-express-v0.2.1/incubator.nodejs-express.templates.simple.tar.gz">https://github.com/appsody/stacks/releases/download/nodejs-express-v0.2.1/incubator.nodejs-express.templates.simple.tar.gz</a><br>Download complete. Extracting files from nodejs-express.tar.gz<br>Setting up the development environment<br>Running command: docker[pull appsody/nodejs-express:0.2]<br>Running command: docker[run — rm — entrypoint /bin/bash appsody/nodejs-express:0.2 -c find /project -type f -name .appsody-init.sh]<br>Successfully initialized Appsody project</pre><p>As well as downloading the latest version of the Appsody Stack (in this case version 0.2), this has added a <strong>.appsody-config.yaml</strong> file to the project, which configures the versions of the Stack that the project will use.<br> <br> While your application is now enabled to use the nodejs-express stack, there are three additional steps that are required to ensure that the Express.js application will work properly with the stack.<br> <br>2. Modify the <strong>package.json</strong> file so that it has a main entry that references the file that contains your Express.js app object:</p><p>In the case of the application created by the Express Application Generator, the <strong>package.json</strong> becomes:</p><pre>{<br>  “name”: “expressjs-app”,<br>  “version”: “0.0.0”,<br>  “private”: true,<br>  “main”: “app.js”,<br>  “scripts”: {<br>    “start”: “node ./bin/www”<br>  },<br>  “dependencies”: {<br>    “cookie-parser”: “~1.4.4”,<br>    “debug”: “~2.6.9”,<br>    “express”: “~4.16.1”,<br>    “http-errors”: “~1.6.3”,<br>    “jade”: “~1.11.0”,<br>    “morgan”: “~1.9.1”<br>  }<br>}</pre><p>Here main references <strong>app.js</strong> as that is the file that contains the Express.js app object. The next step is to export the app object from that file.<br> <br>3. Export the Express.js app object from the file as module.exports.app:</p><p>The last line of the <strong>app.js</strong> file should become:</p><pre>module.exports.app = app;</pre><p>This exposes the app object so that the nodejs-express Appsody stack can apply it onto its own pre-configured Express.js server that includes the cloud-native capabilities.<br> <br>4. Remove any default routes (eg. for 404: Not Found):</p><p>The nodejs-express stack contains default implementations of Health, Readiness and Liveness endpoints. These are designed to be able to be over-ridden by your application. These mean that any default route handles will over-ride those routes.<br> <br> In the application created by the Express Application Generator, this means removing the following statement:</p><pre>// catch 404 and forward to error handler<br>app.use(function(req, res, next) {<br>  next(createError(404));<br>});</pre><p>At this point, your application has been fully enabled. This means that you can now run, test and debug your application in a continuous containerized environment provided by the Appsody Stack, and you get the following additional capabilities, which have been inherited from the stack:</p><p>* Health Endpoint: <a href="http://localhost:3000/health">http://localhost:3000/health</a><br>* Liveness Endpoint: <a href="http://localhost:3000/live">http://localhost:3000/live</a><br>* Readiness Endpoint: <a href="http://localhost:3000/ready">http://localhost:3000/ready</a><br>* Metrics Endpoint: <a href="http://localhost:3000/metrics">http://localhost:3000/metrics</a><br>* Performance Dashboard: <a href="http://localhost:3000/appmetrics-dash">http://localhost:3000/appmetrics-dash</a></p><p>You can also use build to build it into a optimized container image, and deploy to deploy it to Kubernetes.</p><h3>Next Steps</h3><p>To find out how to use the additional capabilities and commands, take a look at the previous articles on “<a href="https://medium.com/appsody/nodes-cloud-packaged-fe60e29b699d">Package your Node.js app for Cloud with Appsody</a>” which covers using the run, test and debug commands, along with the Performance Dashboard, and “<a href="https://medium.com/appsody/nodejs-express-cloud-native-70022e7d5371">Build a new Cloud Native Express.js app with Appsody</a>” which covers more on the nodejs-express Appsody Stack, and more on using the Metrics endpoint.</p><p>For more information on <a href="https://appsody.dev/">Appsody</a>, join us on <a href="http://appsody-slack.eu-gb.mybluemix.net/">Slack</a>, follow us on <a href="https://twitter.com/appsodydev">Twitter</a> and star us on <a href="https://github.com/appsody">GitHub</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f6fc2609bc00" width="1" height="1" alt=""><hr><p><a href="https://medium.com/appsody/nodejs-express-enablement-f6fc2609bc00">Make your Express.js app Cloud-Native with Appsody</a> was originally published in <a href="https://medium.com/appsody">Appsody</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build a new Cloud Native Express.js app with Appsody]]></title>
            <link>https://medium.com/appsody/nodejs-express-cloud-native-70022e7d5371?source=rss-b6e25c635654------2</link>
            <guid isPermaLink="false">https://medium.com/p/70022e7d5371</guid>
            <category><![CDATA[expressjs]]></category>
            <category><![CDATA[cloud-native]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Chris Bailey]]></dc:creator>
            <pubDate>Mon, 15 Jul 2019 14:44:31 GMT</pubDate>
            <atom:updated>2019-12-17T09:19:31.132Z</atom:updated>
            <content:encoded><![CDATA[<p>The use of <a href="https://appsody.dev/">Appsody</a>’s tools and provided Stacks greatly simplies the steps and knowledge required to build “<em>cloud packaged</em>”, “<em>cloud native</em>” and “<em>cloud functions</em>” based applications.</p><p>Appsody’s nodejs-express Stack makes it easy to go beyond making an application “cloud packaged” (which you can see how to do with the basic nodejs Appsody Stack), to creating “cloud native” applications which exploit the capabilities of the cloud platform by providing features such as additional built-in “<strong>Cloud Native</strong>” capabilities such as liveness and readiness, and metrics and observability..</p><p>In the following post, you’ll see how to create a new cloud-native Express.js application using the nodejs-express Stack.</p><h3>Pre-requisites</h3><p>In order to follow this tutorial, you’ll need to install the Apposdy CLI, which also requires you to have Docker installed.</p><h4>Install the Appsody CLI</h4><p>Before getting started, you’ll need to install the Appsody CLI.</p><p>1. Follow the <a href="https://appsody.dev/docs/getting-started/installation">Installing Appsody</a> guide to install the CLI for your platform.</p><p>Additionally, if you’re not familiar with the Appsody’s concepts, its worth reading the “<a href="https://medium.com/appsody/overview-c0cf1f2a244c">Building Cloud-Native Apps with Appsody</a>” article.</p><h3>Creating a new application with the `nodejs-express` Appsody Stack</h3><p>New Appsody based applications are initialized using appsody init &lt;stack&gt; , where the name of the stack is one of those listed when running appsody list. This both downloads the most recent copy of the Appsody Stack, and populates the project directory with a template that provides a basic project structure.</p><p>This needs to be done in a new, empty project directory, and Appsody will then use the name of the directory as the default name for the project.</p><p>1. Create a new directory for your project:</p><pre>mkdir express-app<br>cd express-app</pre><p>2. Initialize a new application using the nodejs-express Stack:</p><pre>appsody init nodejs-express</pre><p>This provides output similar to the following:</p><pre>Running appsody init…<br>Downloading nodejs-express template project from <a href="https://github.com/appsody/stacks/releases/download/nodejs-express-v0.2.1/incubator.nodejs-express.templates.simple.tar.gz">https://github.com/appsody/stacks/releases/download/nodejs-express-v0.2.1/incubator.nodejs-express.templates.simple.tar.gz</a><br>Download complete. Extracting files from nodejs-express.tar.gz<br>Setting up the development environment<br>Running command: docker[pull appsody/nodejs-express:0.2]<br>Running command: docker[run — rm — entrypoint /bin/bash appsody/nodejs-express:0.2 -c find /project -type f -name .appsody-init.sh]<br>Successfully initialized Appsody project</pre><p>This has downloaded a project template that provides a very basic project structure, along with the latest nodejs-express Stack which is a container image that contains:</p><ul><li>A continuous, containerized run, debug and test environment for use during development.</li><li>A pre-configured Express.js server with built-in cloud-native capabilities.</li><li>A build configuration to provide optimized production-read container images for your application.</li></ul><p>Your newly created application contains the following files:</p><pre> 8 -rw-r — r — .appsody-config.yaml<br> 0 drwxr-xr-x .vscode<br> 0 drwxr-xr-x test<br> 8 -rw-r — r — app.js<br> 8 -rw-r — r — package.json</pre><p>Where:</p><ul><li>.appsody-config.yaml configures the Appsody project, primarily controlling with version(s) of the Appsody Stack that the project can use.</li><li>.vscode provides very basic integration with VSCode, including adding <strong>Run Task…</strong> entries for the Appsody CLI commands.</li><li>test contains a set of tests for the application based on the <em>mocha</em> and <em>chai</em> frameworks.</li><li>app.js provides a very simple “Hello from Appsody” Express.js route as an example.</li><li>package.json configured your application, and allows you to add your own additional module dependencies as normal.</li></ul><p>Looking at the <strong>app.js</strong> file in detail, it contains the following:</p><pre>const app = require(&#39;express&#39;)()</pre><pre>app.get(&#39;/&#39;, (req, res) =&gt; {<br>  res.send(“Hello from Appsody!”);<br>});<br> <br>module.exports.app = app;</pre><p>This creates an instance of an Express.js app, and then registers a handler for get() requests on /that send() a response of &quot;Hello from Appsody!&quot;.</p><p>The crucial characteristic that is required for the application to work with the nodejs-express Appsody Stack is that the application exports the create Express.js app using the following line:</p><pre>module.exports.app = app;</pre><p>Ths is required as the Appsody Stack will apply the exported app onto its own pre-configured Express.js server that has already had support for cloud-native capabilities such as liveness and readiness probes, and metrics and observability built in.</p><h3>Developing your application with Appsody</h3><p>Now that you have created your application, the next step is to see it running. To do that you can use the appsody run command in a terminal window. Alternatively, if you use VS Code, you can use the tasks that have been configured in the .vscode directory that was added as part of the template project.</p><ol><li>Run your applcation using: <br>a) From the terminal: appsody run<br>b) In VSCode: <strong>Terminal </strong>&gt; <strong>Run Task…</strong> &gt; <strong>Appsody: run</strong></li></ol><p>This starts a continuous development environment for your application, running inside a container.<br> <br>2. Connect to the application in your browser: <a href="http://localhost:3000/">http://localhost:3000</a></p><p>This responds with:</p><pre>Hello from Appsody!</pre><p>In addition to the handler for get requests on / that was defined in app.js, some other capabilities have been added by the Appsody Stack itself, these include health, liveness and readiness endpoints, a metrics endpoint, and an application performance analysis dashboard (during development only). <br> <br>3. View the additional cloud-native capabilities:</p><ul><li>Health Endpoint: <a href="http://localhost:3000/health">http://localhost:3000/health</a></li><li>Liveness Endpoint: <a href="http://localhost:3000/live">http://localhost:3000/live</a></li><li>Readiness Endpoint: <a href="http://localhost:3000/ready">http://localhost:3000/ready</a></li><li>Metrics Endpoint: <a href="http://localhost:3000/metrics">http://localhost:3000/metrics</a></li><li>Performance Dashboard: <a href="http://localhost:3000/appmetrics-dash">http://localhost:3000/appmetrics-dash</a></li></ul><p>Now that your application is running under appsody run, as you make and save code changes in your application, those will automatically cause your application to be restarted and the changes reflected in the browser.</p><p>4. Make a code change to your project that will be reflected in the browser:</p><p>a) Open the <strong>app.js</strong> file<br> b) Change the file contents to:</p><pre>const app = require(&#39;express&#39;)()<br> <br>app.get(&#39;/&#39;, (req, res) =&gt; {<br>  res.send(“Hello from Appsody!!!!!!!”);<br>});<br> <br>module.exports.app = app;</pre><p>c) Save the file.</p><p>5. Connect to the application in your browser: <a href="http://localhost:3000/">http://localhost:3000</a><br> <br> This will display:</p><pre>Hello from Appsody!!!!!!!</pre><p>6. Finally, stop the continuous run environment by either:</p><ul><li>Using <strong>Ctrl-C</strong> in the terminal window where appsody run is executing</li><li>Running appsody stop from the project directory</li></ul><h4>Testing, Debugging and Performance Analysing your application</h4><p>The Appsody CLI also provides test and debug capabilities, and the built-in Performance Dashboard can be used for performance analysis.</p><p>The these work in exactly the same was as they do for the base nodejs Appsody Stack. You can see how to use those capabilities in the “<a href="https://medium.com/appsody/nodes-cloud-packaged-fe60e29b699d">Package your Node.js app for Cloud with Appsody</a>” article.</p><h3>Using the Metrics endpoint on `/metrics`</h3><p>The Metrics endpoint that is automatically added as part of the nodejs-express Stack is designed to work with the <a href="https://prometheus.io/">Prometheus</a> open source monitoring system.</p><p>While Prometheus can be run anywhere, it is also designed to integrate easily into a Kubernetes environment, and has been embraced by Kubernetes itself — with many of its components exposing metrics for Prometheus to collect.</p><p>This means that, once deployed into Kubernetes, you can visualize data both from your application, and from Kubernetes itself.</p><h4>Installing and configuring Prometheus</h4><p>An instance of Prometheus can easily be setup locally by running it in a container, using its container image from DockerHub. To do that, you’ll first need to setup a configuration file to tell Prometheus what to monitor, and then run with that file:</p><ol><li>Create a file called <strong>prometheus.yml</strong> that contains the following:</li></ol><pre># my global config<br>global:<br>  scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.<br>  evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.<br> # scrape_timeout is set to the global default (10s).</pre><pre># A scrape configuration containing exactly one endpoint to scrape:<br>scrape_configs:<br> # The job name is added as a label `job=&lt;job_name&gt;` to any timeseries scraped from this config.<br>  - job_name: &#39;prometheus&#39;<br>    static_configs:<br>    - targets: [&#39;localhost:9090&#39;]<br> <br>  - job_name: &#39;nodejs-app&#39;<br>    static_configs:<br>    - targets: [&#39;host.docker.internal:3000&#39;]</pre><p>The scrape_configs section tells Prometheus which applications to monitor, their location and port. By default, Prometheus will make http requests on /metrics.</p><p>Note that for our nodejs-app, the target has an address of host.docker.internal. This is special address that tells Docker to connect to the localhost of the machine on which the docker container is running.</p><p>2. Run Prometheus in a container using docker:</p><pre>docker run --rm -d -p 9090:9090 --name=prometheus -v $PWD/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus</pre><p>3. Connect to Prometheus in your browser: <a href="http://localhost:9090/">http://localhost:9090</a></p><p>This shows the following view where you can display graphs and data:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F5KOAHrAxKbfeM87s_s6zQ.png" /><figcaption>Prometheus Dashboard View</figcaption></figure><p>Before doing that, first see what “targets” Prometheus is collecting data from:</p><p>4. Select <strong>Status</strong> &gt; <strong>Targets</strong></p><p>This shows a list of two servers that Prometheus is collecting data from:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iCbfDAYMhOkMVqvSmp3hfw.png" /><figcaption>Prometheus Target Status View</figcaption></figure><p>This show that Prometheus is collecting data itself as well as your application, and that both have a state of UP.<br> <br>5. Select <strong>Graph</strong> two switch back to the Graph view, and then display some data: <br> a) Enter http_request_duration_microseconds in the <strong>Expression</strong> box<br> b) Click on the <strong>Graph</strong> tab</p><p>This displays a graph of the the performance of requests to various HTTP endpoints in your application:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V6OaKFUSCn1WDdyfjB4Y0w.png" /><figcaption>Promethus Graph View with Request Duration Data</figcaption></figure><p>This shows that Prometheus has data for requests against / and /favicon.ico.</p><p>6. Next, make some requests of your application in your browser, and refresh the Graph page in the Prometheus dashboard</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tEIbuGPFgnOMY8a3QhWx-w.png" /><figcaption>Promethus Graph View with Request Duration Data</figcaption></figure><p>This now shows the variation in performance as the application is responding to ongoing requests.</p><p>Prometheus provides the ability to build simple graphs and alerts. However, it is also designed to be used with more advanced graphing and dashboarding solutions. The most frequently used being Grafana.</p><h4>Installing Grafana</h4><p><a href="https://grafana.com/">Grafana</a> can also easily be setup and run locally using its container image from DockerHub, and the connect it to the running Prometheus instance. To do that, you’ll first need to run Grafana itself, and then configure it use your Prometheus server so that has access to the data that Prometheus us collecting.</p><p>1. Run Grafana in a container using docker:</p><pre>docker run --rm -d -p 3001:3000 --name=grafana -e “GF_SECURITY_ADMIN_PASSWORD=password” grafana/grafana</pre><p>2. Open the Grafana console: <a href="http://localhost:3001/">http://localhost:3001</a></p><p>3. Login with the following credentials:</p><ul><li>Username: admin</li><li>Password: password</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kl8-ejpc88Jr34zyzfPW6Q.png" /><figcaption>Grafana Login Page</figcaption></figure><p>Note that the password of password was set using the GF_SECURITY_ADMIN_PASSWORD value when you started the Grafana server using docker.<br> <br>4. In the Home Dashboard display, click on <strong>Add data source</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7Z-oe1udHhYDor4X2XZQkg.png" /><figcaption>Adding a data source in Grafana</figcaption></figure><p>5. Select the <strong>Prometheus</strong> icon for the data source type:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4hxvLa9C-Uu_gq8-09CMsg.png" /><figcaption>Selecting the Prometheus data source</figcaption></figure><p>6. Enter a <strong>URL</strong> of http://host.docker.internal:9090and click <strong>Save &amp; Test</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Sgm9VB1cIDXhtcAzQFfSog.png" /><figcaption>Setting the data source values in Grafana</figcaption></figure><p>7. Select the <strong>+</strong> button on the left hand side-bar and click on <strong>Dashboard</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6Ysk2lfnRW-c8pn5o7bPbQ.png" /><figcaption>Creating a new Dashboard in Grafana</figcaption></figure><p>This will create a new dashboard for you, in which you can start to create panels to display visualizations, queries and data.</p><p>8. Click on the <strong>Add Query</strong> icon</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qJjtUyTpxGlzOhNKKayp8w.png" /><figcaption>Add a new panel using Add Query</figcaption></figure><p>This opens a new query and visualization panel.</p><p>9. In the entry box next to <strong>A</strong>, enter the following query:</p><pre>http_request_duration_microseconds</pre><p>and then click on the graph at the top of the panel.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ft4jMGquH9a9a-i7-MkKew.png" /><figcaption>Adding aquery and creating a graph</figcaption></figure><p>This will now display a chart of the HTTP responsiveness for all of the applications that Prometheus collecting data from.<br> <br>10. Add a filter and calculation to the query so that it only displays data from your application by modifying the query to the following:</p><pre>http_request_duration_microseconds{job=”nodejs”}/1000 </pre><p>and then click on the graph at the top of the panel.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5xP1ibNUStXgvcRkxImoWA.png" /><figcaption>Filtered graph, displayed in milliseconds</figcaption></figure><p>This has filtered the graph to only display data from the application with the job name of nodejsn — this is the value you set for your application in the <strong>prometheus.yml</strong> file when you started Prometheus — and then divides the data by 1000 to give a time in milliseconds rather than microseconds.<br> <br>11. Finally, click the “<strong>Disk</strong>” icon at the top of the window to save your dashboard, giving it a name and clicking on the <strong>Save</strong> button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GoyHsHjHYJ6uNUrbI3QAhQ.png" /><figcaption>Save the Dashboard</figcaption></figure><p>Grafana makes it possible to build rich and dynamic dashboards so that you can visualize your data however you wish. It also lets you import pre-built dashboards.</p><p>To see the catalog of available dashboards, visit the <a href="https://grafana.com/dashboards">Dashboards</a> page on Grafana.com.</p><h4>Cleaning Up</h4><p>Finally, to shut down Prometheus and Grafana, you need to stop their running containers. You can do that with the following two commands:</p><pre>docker stop prometheus<br>docker stop grafana</pre><h3>Next Steps</h3><p>This article covered how to build new “Cloud-Native” Express.js application using the nodejs-express Appsody Stack which automatically provides the application with cloud-native capabilities such as liveness and readiness checks, along with metrics and observability.</p><p>In the next article: “<a href="https://medium.com/appsody/nodejs-express-enablement-f6fc2609bc00">Make your Express.js app Cloud-Native with Appsody</a>”, we’ll look at how its possible to take an existing Express.js application and enable it to use the nodejs-express Appsody Stack.</p><p>For more information on <a href="https://appsody.dev/">Appsody</a>, join us on <a href="http://appsody-slack.eu-gb.mybluemix.net/">Slack</a>, follow us on <a href="https://twitter.com/appsodydev">Twitter</a> and star us on <a href="https://github.com/appsody">GitHub</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=70022e7d5371" width="1" height="1" alt=""><hr><p><a href="https://medium.com/appsody/nodejs-express-cloud-native-70022e7d5371">Build a new Cloud Native Express.js app with Appsody</a> was originally published in <a href="https://medium.com/appsody">Appsody</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Package your Node.js app for Cloud with Appsody]]></title>
            <link>https://medium.com/appsody/nodes-cloud-packaged-fe60e29b699d?source=rss-b6e25c635654------2</link>
            <guid isPermaLink="false">https://medium.com/p/fe60e29b699d</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[cloud-native]]></category>
            <dc:creator><![CDATA[Chris Bailey]]></dc:creator>
            <pubDate>Mon, 15 Jul 2019 14:37:19 GMT</pubDate>
            <atom:updated>2019-07-16T12:03:13.073Z</atom:updated>
            <content:encoded><![CDATA[<p>The use of <a href="https://appsody.dev/">Appsody</a>’s tools and provided Stacks greatly simplifies the steps and knowledge required to build “<em>cloud packaged</em>”, “<em>cloud native</em>” and “<em>cloud functions</em>” based applications.</p><p>Appsody’s nodejs Stack makes it easy to take any existing Node.js application and make it “cloud packaged”.</p><p>In the following post, you’ll see how to take a sample Node.js application, and package it into a best-practise container image using the Appsody CLI and the nodejsStack.</p><h3>Pre-requisites</h3><p>In order to follow this tutorial, you’ll need to install the Appsody CLI, which also requires you to have Docker installed, along with a Node.js application to cloud package.</p><p><strong>Install the Appsody CLI</strong><br>Before getting started, you’ll need to install the Appsody CLI.</p><p>1. Follow the <a href="https://appsody.dev/docs/getting-started/installation">Installing Appsody</a> guide to install the CLI for your platform.</p><p><strong>Create a sample application</strong><br>Additionally, you’ll need a Node.js app to package. You can either use one you already have, or create an sample Express.js using the following steps:</p><p>1. Install the <a href="http://expressjs.com/en/starter/generator.html">Express.js Application Generator</a>:</p><pre>npm install -g express-generator</pre><p>2. Create a directory for your application:</p><pre>mkdir nodejs-app<br>cd nodejs-app</pre><p>3. Run the Express Application Generator to build a sample application:</p><pre>express</pre><p>4. Run your generated Express.js application:</p><pre>npm install<br>npm start</pre><p>5. Open your browser to see the application running: <a href="http://localhost:3000/">http://localhost:3000</a><br> This will display:</p><figure><img alt="“Express” and “Welcome to Express” displayed in the browser window." src="https://cdn-images-1.medium.com/max/906/1*DlK8tQFakRCUgK3FMN4iRw.png" /><figcaption>Express: Welcome to Express</figcaption></figure><p>6. Stop the Express.js application using <strong>Ctrl-C</strong></p><p>Your sample application is now ready to use!</p><h3>Enabling your application with the nodejs Appsody Stack</h3><p>New Appsody based applications are created using appsody init &lt;stack&gt;, where the name of the stack is one of those listed when running appsody list. This both downloads the most recent copy of the Appsody Stack, and populates the project directory with a template that provides a basic project structure.</p><p>In order to enable an existing application with a stack, the same steps can be followed, but using the --no-template option to appsody init as a project structure is not required.</p><p>1. Enable the Node.js Application:</p><pre>appsody init nodejs --no-template</pre><p>This will print output similar to the following to the console:</p><pre>Running appsody init…<br>Downloading nodejs template project from <a href="https://github.com/appsody/stacks/releases/download/0.2.0/incubator.nodejs.templates.simple.tar.gz">https://github.com/appsody/stacks/releases/download/0.2.0/incubator.nodejs.templates.simple.tar.gz</a><br>Download complete. Extracting files from nodejs.tar.gz<br>Setting up the development environment<br>Running command: docker[pull appsody/nodejs:0.2]<br>Running command: docker[run — rm — entrypoint /bin/bash appsody/nodejs:0.2 -c find /project -type f -name .appsody-init.sh]<br>Successfully initialized Appsody project</pre><p>As well as downloading the latest version of the Appsody Stack (in this case version 0.2), this has added a <strong>.appsody-config.yaml</strong> file to the project, which configures the versions of the Stack that the project will use.<br> <br>At this point, your application has been enabled, which means you can now run , test and debug your application in a continuous containerized environment provided by the Appsody Stack, to build it into a optimized container image, and to deploy it to Kubernetes.</p><h3>Developing your application with Appsody</h3><p>Now that your application has been enabled, you can use the run, test and debugcommands to the Appsody CLI to work with your application in a continuous containerized environment provided by the Appsody Stack.</p><h4>Working with your application in Run mode</h4><p>Appsody’s run mode provides a continuous development environment, where changes that are saved to your project cause your application to be restarted. This is similar to the experience you get from tool like <a href="https://nodemon.io/">nodemon</a>, but this occurs inside the containerised environment. The only requirement is that your applications’ <strong>package.json</strong> file needs to include a <strong>start</strong> script.</p><p>The following steps show you how that works for your application:</p><ol><li>Open your application in your favourite IDE <br>Alternatively you can open a second terminal window so that you can edit the application files.</li><li>Start the continuous run environment, by using the Appsody CLI in the terminal window:</li></ol><pre>appsody run</pre><p>3. Open your browser to see the application running: <a href="http://localhost:3000/">http://localhost:3000</a><br> This will display:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/906/1*DlK8tQFakRCUgK3FMN4iRw.png" /></figure><p>As appsody run provides a continuous development environment, any code changes you make will cause an automatic restart of the application.</p><p>4. Make a code change to your project that will be reflected in the browser:</p><p>a) Open <strong>views</strong> &gt; <strong>index.jade</strong></p><p>b) Change the file contents to:</p><pre>extends layout<br> <br>block content<br>  h1= title<br>  p Welcome to #{title}!!!!!!!</pre><p>c) Save the file</p><p>5. Open your browser to see the application running: <a href="http://localhost:3000/">http://localhost:3000</a><br> This will display:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/906/1*exACNK8Vy3npizac03lxpQ.png" /><figcaption>Express: Welcome to Express!!!!!!!</figcaption></figure><p>This provides a continuous, containerized development environment where you can almost instantly see any changes you make reflected in the application running in the browser.</p><h4>Carrying out Performance Analysis of your application</h4><p>As well as providing the development environment, both appsody run and appsody debug also injects a development-time only feature that adds a performance monitoring and profiling dashboard using the <a href="https://www.npmjs.com/package/appmetrics-dash">appmetrics-dash</a> module, which enables you to do analysis of your application.</p><ol><li>Open the Performance dashboard: <a href="http://localhost:3000/appmetrics-dash/">http://localhost:3000/appmetrics-dash/</a></li></ol><p>This provides a display similar to the following, which provides data for:</p><ul><li>HTTP request responsiveness and HTTP throughput</li><li>Performance of outbound HTTP requests and other requests</li><li>Event Loop latency showing the delay before tasks are scheduled.</li><li>CPU and Memory usage for the process and the system</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kY0UpLoAlH4ICB-TKXUKqg.png" /><figcaption>Performance Monitoring and Analysis Dashboard</figcaption></figure><p>2. Click on the <strong>Profiling</strong> tab to open the profiling view</p><p>3. Click on the “<strong>Hamburger Menu</strong>” (the three horizontal lines in the top left-hand corner” and select <strong>Enable Profiling</strong></p><p>This starts to collect function profiling data from the application, and to visualize it using a <a href="http://www.brendangregg.com/flamegraphs.html"><em>flame graph</em></a>, which providing a visualization of the stacks and functions that are using most CPU time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aOu1LuWy7ZAZYuUXbZvUBg.png" /><figcaption>Flame Graph generated from Performance Profiling Data</figcaption></figure><p>4. Click on the “<strong>Hamburger Menu</strong>”(the three horizontal lines in the top left hand corner” and select <strong>Disable Profiling</strong><br> <br>As well as providing performance monitoring and profiling, you can also trigger Heap Dumps and <a href="https://github.com/nodejs/node-report">Node Reports</a> through the menu,and see an overview of your application in the Summary tab.</p><p>5. Finally, stop the continuous `run` environment by either:</p><ul><li>Using <strong>Ctrl-C</strong> in the terminal window where appsody run is executing</li><li>Running appsody stop from the project directory</li></ul><h4>Working with your application in Debug mode</h4><p>Appsody’s debug mode provides the same continuous development environment that you get with the run environment, with the addition of running the application in debug mode and providing the correct configuration to enable remote access from a local debugger.</p><p>The following steps show you how that works for your application:</p><ol><li>Open your application in your favourite IDE <br> Alternatively you can open a second terminal window so that you can edit the application files.</li><li>Start the continuous debug environment, by using the Appsody CLI in the terminal window:</li></ol><pre>apposody debug</pre><p>3. Open your browser to see the application running: <a href="http://localhost:3000/">http://localhost:3000</a><br> This will display:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/906/1*exACNK8Vy3npizac03lxpQ.png" /><figcaption>Express: Welcome to Express!!!!!!!</figcaption></figure><p>As appsody debug provides a continuous development environment, any code changes you make will cause an automatic restart of the application. It also sets up the container to allow remote access from a debugger.<br> <br>4. Attach a debugger to your application <br> You can either used your favourite debugger for this, or use the one integrated into the Chrome Browser as follows:<br> a) Open the Chrome Browser<br> b) Enter chrome://inspect in the search window</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T9rajU9OqnhBe1ULjWWPzg.png" /><figcaption>chrome://inspect in the search bar</figcaption></figure><p>This will display a view similar to the following in the window:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cCAYJOIIr86Qdilvs9Btfw.png" /><figcaption>Available targets to inspect with the Chrome Debugger</figcaption></figure><p>3. Select the <strong>inspect</strong> link for the application shown under <strong>Remote Target</strong></p><p>This will then open a new panel containing the debugger, attached to your application running inside the continues containerized debug environment.</p><p>You can now debug as you would normally. Additionally, any code change that you make to the project through changes to its source code with automatically stop and restart your application (after which you will need to restart the debugger connection).</p><p>4. Finally, stop the continuous debug environment by either:</p><ul><li>Using <strong>Ctrl-C</strong> in the terminal window where appsody debug is executing</li><li>Running appsody stop from the project directory</li></ul><h3>Working with your application in Test mode</h3><p>Appsody’s test mode makes it possible to run any tests that your application has inside the containerized environment. To use this capability, your application needs to be provides some tests, and your <strong>package.json</strong> file needs to include a <strong>test</strong> script that runs them.</p><p>The steps below show how that works for your application. As the sample application created from the Express Application Generate does not include any tests, you first need to add one.</p><p>1. Update your <strong>package.json</strong> file to add devDependencies for chai, mocha and request, and add a test script:</p><pre>{<br>  “name”: “test”,<br>  “version”: “0.0.0”,<br>  “private”: true,<br>  “scripts”: {<br>    “start”: “node ./bin/www”,<br>    “test”: “mocha”<br>  },<br>  “dependencies”: {<br>    “cookie-parser”: “~1.4.4”,<br>    “debug”: “~2.6.9”,<br>    “express”: “~4.16.1”,<br>    “http-errors”: “~1.6.3”,<br>    “jade”: “~1.11.0”,<br>    “morgan”: “~1.9.1”<br>  },<br>    “devDependencies”: {<br>    “chai”: “⁴.2.0”,<br>    “mocha”: “~6.1.0”,<br>    “request”: “².88.0”<br>  }<br>}</pre><p>2. Create a new <strong>test</strong> directory in your project:</p><pre>mkdir test<br>cd test</pre><p>3. Create a new <strong>test</strong> &gt; <strong>test.js </strong>file containing:</p><pre>const expect = require(‘chai’).expect;<br>const request = require(‘request’);<br>const app = require(‘../app’);<br>var http = require(‘http’);<br> <br>const PORT = process.env.PORT || ‘3000’;<br>const server = app.listen(PORT);<br>const url = “<a href="http://localhost/">http://localhost</a>:&quot; + PORT;<br> <br>describe(“Node.js Stack”, function () {<br> <br>  // Testing / responds with 200 OK <br>  describe(‘/ endpoint OK’, function () {<br>    it(‘status’, function (done) {<br>      request(url + ‘/’, function (error, response, body) {<br>        expect(response.statusCode).to.equal(200);<br>        done();<br>      });<br>    });<br>  });<br>});<br> <br>// Stop the server after testing<br>after(done =&gt; {<br>  server.close(done);<br>}); </pre><p>4. Check that the tests are running locally:</p><pre>npm install<br>npm test </pre><p>This will respond with output similar to the following:</p><pre>Node.js Stack<br>/ endpoint OK<br>GET / 200 309.872 ms — 170<br>✓ status (341ms)</pre><pre>1 passing (354ms) </pre><p>5. Run the tests using the Appsody test mode:</p><pre>appsody test</pre><p>This will respond with output that includes the following:</p><pre>[Container] &gt; test@0.0.0 test /project/user-app<br>[Container] &gt; mocha<br>[Container] <br>[Container] <br>[Container] <br>[Container] Node.js Stack<br>[Container] / endpoint OK<br>[Container] GET / 200 320.079 ms — 170<br>[Container] null<br>[Container] ✓ status (359ms)<br>[Container] <br>[Container] <br>[Container] 1 passing (375ms)</pre><p>Note that, unlike run anddebug, test executes a single run of the tests rather than a continuous container.</p><h3>Building your application with Appsody</h3><p>Once you have reached a point that you would like to build a deployable container image for your application, you can do that using appsody build. This creates a production-optimized image that is built using the regular <a href="https://hub.docker.com/_/node">“node” Official Docker image</a> from the Node.js community and then rebased on the communities “node-slim” image. The “node-slim” image is both significantly smaller that the regular “node” image, making it easier and faster to deploy to a cloud, and more secure because it does not include packages like compilers (which are required in the regular “node” image to allow you to use packages with native add-ons).</p><p>The steps below show how to build the container image for your application, and then run it locally using Docker:</p><p>1. Build the container image for your application:</p><pre>appsody build</pre><p>This builds a container image for your application, using the name of your project as the “tag” (which is the name of the folder in which is resides). The final line of the output gives the name of the image:</p><pre>Built docker image nodejs-app</pre><p>2. Run the container image using Docker:</p><pre>docker run — rm -p 3000:3000 -i -t nodejs-app</pre><p>This runs your container image, using the-p option to map port 3000 from the container to port 3000 on your machine, the -i option to run interactively (so you can use <strong>Ctrl-C</strong> to stop the container), the --rm option to remove the container when its stopped, and the -t option to run the container image with our “tag” of nodejs-app.<br> <br>3. Open your browser to see the application running: <a href="http://localhost:3000/">http://localhost:3000</a></p><p>Note that the Performance Dashboard is not present, as it was injected as a development-only feature.<br> <br>4. Finally, stop the container by using <strong>Ctrl-C</strong> in the terminal window where docker run is executing.</p><p>You now have a cloud packaged available in a container image that is ready to be deployed to any cloud that supports container images.</p><p>You can also use the appsody deploy command to <a href="https://appsody.dev/docs/using-appsody/building-and-deploying">deploy the image to any Kubernetes cluster</a>.</p><h3>Next Steps</h3><p>This article covered how to take an existing Node.js application and make it “<em>Cloud Packaged</em>” using the nodejs Appsody Stack. Appsody also provides a higher level nodejs-express stack that additionally provides a pre-configured Express.js server that includes cloud-native capabilities such as liveness and readiness checks, along with metrics and observability.</p><p>You can see how to use that stack in the following two articles:</p><ul><li><a href="https://medium.com/appsody/nodejs-express-cloud-native-70022e7d5371">How to build a Cloud Native Express.js app with Appsody</a></li><li><a href="https://medium.com/appsody/nodejs-express-enablement-f6fc2609bc00">How to make your existing Express.js app Cloud Native with Appsody</a></li></ul><p>For more information on <a href="https://appsody.dev/">Appsody</a>, join us on <a href="http://appsody-slack.eu-gb.mybluemix.net/">Slack</a>, follow us on <a href="https://twitter.com/appsodydev">Twitter</a> and star us on <a href="https://github.com/appsody">GitHub</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fe60e29b699d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/appsody/nodes-cloud-packaged-fe60e29b699d">Package your Node.js app for Cloud with Appsody</a> was originally published in <a href="https://medium.com/appsody">Appsody</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building Cloud-Native Apps with Appsody]]></title>
            <link>https://medium.com/appsody/overview-c0cf1f2a244c?source=rss-b6e25c635654------2</link>
            <guid isPermaLink="false">https://medium.com/p/c0cf1f2a244c</guid>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[knative]]></category>
            <category><![CDATA[cloud-native]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Chris Bailey]]></dc:creator>
            <pubDate>Mon, 15 Jul 2019 14:36:06 GMT</pubDate>
            <atom:updated>2019-07-16T14:00:45.308Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://appsody.dev/">Appsody</a> provides a set of open source tools and capabilities that simplifies the process of building and deploying applications to Kubernetes that are not just cloud packaged, but that are also cloud native.</p><p>To do that, Appsody provides three components:</p><ul><li>Appsody CLI</li><li>Appsody Stacks</li><li>Appsody Deploy</li></ul><h3>Appsody CLI</h3><p>The Appsody CLI provides commands that implement the full development lifecycle. This spans the ability to create a new or enable an existing application using init , to then run, test, and debug, and finally to build an image and deploy it to Kubernetes.</p><figure><img alt="Flow diagram showing how the Appsody CLI implements create, run, test, debug, build and deploy for cloud-native applications." src="https://cdn-images-1.medium.com/max/1024/1*DD5jgarKafBCjJYDYv5sXQ.png" /><figcaption>Appsody Workflow with the Appsody CLI</figcaption></figure><p>All of this occurs in a continuous, local containerized environment. This means that, regardless of your development machine’s operating system, you can immediately verify, test and debug your application in a containerized environment that closely matches your target deployment environment.</p><p>Additionally, the local containerized environment supports continuous build and run, meaning that code changes that you make in your application are immediately reflected in the container.</p><h3>Appsody Stacks</h3><p>At the heart of Appsody is the concept of Stacks. These provide pre-built, cloud-optimized development and production configurations for a range of programming languages and microservice frameworks. These are then discoverable and shareable through the Appsody Hub repository.</p><p>Building traditional cloud applications means not just creating the application itself, but also building-in cloud-native capabilities. For example, liveness and readiness, metrics and observability, and dynamic configuration. That application then needs to be packaged for cloud using best practise Dockerfiles to create production optimized container images. This requires the accumulation of significant knowledge of how to integrate with cloud capabilities, as well as writing and maintaining the integration code. All of this <em>could</em> be delegated, which Appsody does by adding the capabilities into the Appsody Stacks.</p><p>Appsody Stacks are designed to provide a spectrum of capabilities dependent on how much of the cloud-native application you want to write yourself, and how much you want to delegate to the Stack.</p><figure><img alt="Diagram showing the range of stacks for Node.js, spanning those for Cloud Packaging, Cloud Native and Cloud Functions" src="https://cdn-images-1.medium.com/max/1024/1*cFBKZP13GOLTDq3707ayDw.png" /><figcaption>Appsody Stacks for Node.js</figcaption></figure><p>At the most simple level, the Appsody Stack provides “<strong>Cloud Packaging</strong>” for your chosen language. This means that you can either bring an existing application or build a new application, and the Appsody Stack not only provides a continuous containerized run, test and debug environment, but can also be used to build a best-practise container image for your application, and then deploy it to a local or remote Kubernetes cluster.</p><p>At the next level, the Appsody Stack provides additional built-in “<strong>Cloud Native</strong>” capabilities such as liveness and readiness, metrics and observability. This is achieved by providing a pre-configured microservice or web framework as part of the Stack itself. You can then develop your code using the standard APIs from the framework as you would normally; Appsody then <em>composes</em> the application with the Stack to provide a full, containerized microservice.</p><p>At the highest level, the Appsody Stack provides “<strong>Cloud Functions</strong>”-like APIs, where the Appsody Stack itself contains a full, cloud-native microservice. You can then develop by writing functions, using either the HTTP APIs provided by the framework or generic APIs such as those provided by Lambda, OpenWhisk and others. Appsody then <em>composes</em> with the Stack to provide a full, containerized, microservice with your functions.</p><p>This means that you can choose the level of function <em>you</em> want to provide, versus what is provided by the Stack. You can, of course, also create your own Stacks — these are just source projects that contain pre-configured microsevice or web frameworks which are built into standard container images.</p><h3>Appsody Deploy</h3><p>Finally, you can build you application into a standard, production-optimized container image using the Appsody build command, or build and deploy the image into Kubernetes using the Appsody deploy command. This makes it easy to test and verify how your application runs when deployed into Kubernetes.</p><p>The built container image can then be used in the same way that you would use any other image — enabling you to run it using Docker directly, or to deploy it to any cloud that supports containers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*945AX26l4kUN6nLft9_uDw.png" /><figcaption>Cloud Deploy to Kubernetes using Knative</figcaption></figure><p>Additionally, the Appsody `deploy` command can deploy directly to any Kubernetes cluster that has <a href="https://knative.dev/">Knative Serving</a> installed. The use of Knative serving means that the deployed application scales on request — and down to zero when its not use — and automatically has routes set up for it, so its immediately testable from your browser.</p><h3>See it in action</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fa1ww3W1ZVto%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Da1ww3W1ZVto&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fa1ww3W1ZVto%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/99f11783bdd76369d5431cb124ffe5d0/href">https://medium.com/media/99f11783bdd76369d5431cb124ffe5d0/href</a></iframe><h3>Try it out!</h3><p>You can get started with Appsody using the getting started guide on the Appsody Website, or by using one of the following tutorials that describe how to use some of the Appsody Stacks:</p><ul><li><a href="https://medium.com/appsody/nodes-cloud-packaged-fe60e29b699d">How to package your Node.js app with Appsody</a></li><li><a href="https://medium.com/appsody/nodejs-express-cloud-native-70022e7d5371">How to build a Cloud Native Express.js app with Appsody</a></li><li><a href="https://medium.com/appsody/nodejs-express-enablement-f6fc2609bc00">How to make your existing Express.js app Cloud Native with Appsody</a></li></ul><p>For more information on <a href="https://appsody.dev/">Appsody</a>, join us on <a href="http://appsody-slack.eu-gb.mybluemix.net/">Slack</a>, follow us on <a href="https://twitter.com/appsodydev">Twitter</a> and star us on <a href="https://github.com/appsody">GitHub</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c0cf1f2a244c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/appsody/overview-c0cf1f2a244c">Building Cloud-Native Apps with Appsody</a> was originally published in <a href="https://medium.com/appsody">Appsody</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[IBM Cloud Private adds support for Open Source Java, Node.js]]></title>
            <link>https://medium.com/ibm-cloud/ibm-cloud-private-adds-support-for-open-source-java-node-js-dc01ca205c9c?source=rss-b6e25c635654------2</link>
            <guid isPermaLink="false">https://medium.com/p/dc01ca205c9c</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[loopback]]></category>
            <category><![CDATA[expressjs]]></category>
            <dc:creator><![CDATA[Chris Bailey]]></dc:creator>
            <pubDate>Thu, 21 Jun 2018 16:27:25 GMT</pubDate>
            <atom:updated>2018-06-21T16:31:38.192Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>IBM Cloud Private adds support for Open Source Java, Node.js and Swift runtimes and select Frameworks</strong></h3><p>Whether modernizing existing applications or building new cloud native microservices, cloud based applications are increasingly composed of components built using multiple programming languages and frameworks. This is why IBM Cloud Private now includes service and support for the open source Java, Node.js and Swift runtimes along with select web and microservice frameworks, enabling you to build out best-practice architecture patterns:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Auu_C-mTT-ClkhoeocT1Kg.png" /><figcaption>(<a href="https://www.ibm.com/cloud/garage/videos/deploying-microservices-to-cloud">https://www.ibm.com/cloud/garage/videos/deploying-microservices-to-cloud</a>)</figcaption></figure><p>This further enhances the value provided by IBM Cloud Private by expanding the range of applications and workloads that can be deployed to it with the guarantee of enterprise levels of support. This new support is included with the 2.1.0.3 version of IBM Cloud Private, Cloud Native Edition.</p><p>In addition to the existing support for applications and microservices built using IBM WebSphere Liberty, IBM Cloud Private now provides support for applications built using:</p><h3><strong>Open source Java using OpenJDK with OpenJ9</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/390/1*LGcmFGAGdOSKkiB0FOkPxw.png" /><figcaption>OpenJDK with OpenJ9</figcaption></figure><p>Java, with 12 million developers and over 50 million internet facing instances including some of the highest traffic websites in the world, is the cornerstone of enterprise applications. This spans both applications being modernized today and the new breed of microservices. The addition of support for <a href="https://www.eclipse.org/openj9/">OpenJDK with OpenJ9</a> enables you to run frameworks other than WebSphere Liberty with the confidence that you can get support for the Java runtime.</p><h3><strong>Open source Node.js, along with the Express and Loopback frameworks</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/816/1*dwDpjz3KSVdBXEMsLh80Dw.png" /><figcaption>Node.js, Express.js and LoopBack</figcaption></figure><p><a href="https://nodejs.org/">Node.js</a>, the server-side JavaScript runtime, has grown dramatically over the last few years and now counts 4 million developers with 9 million deployed instances. That growth is continuing, with almost a doubling of usage over the last year, and solidifying adoption in enterprises with production deployments at a number of major companies. The addition of support for Node.js itself as well as the <a href="http://expressjs.com/">Express.js</a> and <a href="https://loopback.io/">Loopback</a> frameworks, means that IBM Cloud Private now includes support for over 95% of Node.js based web and microservice framework usage.</p><h3><strong>Open source Swift, along with the Kitura framework</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/822/1*Dw09gbGoXzleQwb-eH68gw.png" /><figcaption>Swift and Kitura</figcaption></figure><p><a href="https://swift.org/">Swift</a>, the Apple-created programming language for iOS devices that is now available on the server, is the fastest language to enter the top ten of the RedMonk programming language rankings. Whilst open source for only just over two years, it already has 2.4 million developers and is rapidly growing in usage to build backend services for mobile applications, with over a 400% growth in server usage in the last year. The addition of support for Swift itself as well as the <a href="https://www.kitura.io/">Kitura</a>, the most popular server-side Swift framework amongst enterprise users, means that IBM Cloud Private now enables fullstack mobile backends to be built and deployed for iOS devices.</p><p><strong>What versions are supported?</strong></p><p>Support is provided for the version(s) that are considered to be current and in-support by the respective community at the time of the request. For example, this means all <a href="https://github.com/nodejs/Release#release-schedule">Long Term Support (LTS) versions of Node.js</a>.</p><p>Terms and conditions of support for each open source runtime can be found included in the <a href="http://www-03.ibm.com/software/sla/sladb.nsf/lilookup/270B9901E0C62BC385258298001AC27C?OpenDocument">IBM Cloud Private 2.1.0.3 (5737-E67)</a> license file.</p><p><strong>Get Started Today</strong></p><p>To get starting building and deploying applications using the open source runtimes and frameworks, download <a href="https://www.ibm.com/support/knowledgecenter/en/SSBS6K_2.1.0.3/installing/install_containers_CE.html">IBM Cloud Private Community Edition</a> today. Either bring your existing applications that use the open source runtimes from <a href="http://adoptopenjdk.net/">AdoptOpenJDK.net</a>, <a href="http://nodejs.org/">nodejs.org</a> or <a href="http://swift.org/">swift.org</a> by providing your own Docker images. Or build your applications using our <a href="https://microclimate-dev2ops.github.io/">Microclimate</a> tools, or the framework specific tools for <a href="http://expressjs.com/">Express</a>, <a href="http://loopback.io/">Loopback</a> or <a href="http://kitura.io/">Kitura</a>. When ready for a supported environment ensure your applications are deployed on IBM Cloud Private, Cloud Native Edition.</p><p><em>Open source runtimes and select frameworks above are not distributed with IBM Cloud Private. Clients must download the runtimes and frameworks directly from the open communities, selecting a supported version as defined in the IBM Cloud Private license. It is the client’s responsibility to build their application as a container image with the runtimes and deploy on IBM Cloud Private, Cloud Native edition.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dc01ca205c9c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ibm-cloud/ibm-cloud-private-adds-support-for-open-source-java-node-js-dc01ca205c9c">IBM Cloud Private adds support for Open Source Java, Node.js</a> was originally published in <a href="https://medium.com/ibm-cloud">IBM Cloud</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>