<?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[Stackahoy - Medium]]></title>
        <description><![CDATA[Thoughts and opinions on cloud computing automation by the makers of stackahoy.io. - Medium]]></description>
        <link>https://medium.com/stackahoy?source=rss----2ab958ee9680---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Stackahoy - Medium</title>
            <link>https://medium.com/stackahoy?source=rss----2ab958ee9680---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 20:22:56 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/stackahoy" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Image Processing as a Microservice]]></title>
            <link>https://medium.com/stackahoy/image-processing-go-microservice-df423d1b8ddd?source=rss----2ab958ee9680---4</link>
            <guid isPermaLink="false">https://medium.com/p/df423d1b8ddd</guid>
            <category><![CDATA[go]]></category>
            <category><![CDATA[image-processing]]></category>
            <category><![CDATA[gcp]]></category>
            <category><![CDATA[gce]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Pete Saia]]></dc:creator>
            <pubDate>Sun, 22 Apr 2018 18:12:24 GMT</pubDate>
            <atom:updated>2018-04-03T14:31:00.980Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TcuIY4tb9tuzI1bnOJEoog.jpeg" /><figcaption>Go + GCP = 🚀</figcaption></figure><h3><strong>Distributed State of Mind</strong></h3><p>When creating a distributed system, photo handling becomes less trivial. At the first signs of scale it can become a real pain point in the application. Why?</p><ul><li>Mounting multiple running nodes to the same persistent storage is impossible — for good reason. If it isn’t with some providers/stores, you will have to worry about data corruption during writes.</li><li>Storing and serving (bill|mill|trill)ions of images on a disk and serving them yourself isn’t fun and is error prone. You also probably won’t be able to serve it as quickly as Google.</li><li>Image manipulation (resizing, cropping, auto-orientation) is resource intensive. In a distributed system, you want your nodes to have maximum capacity for throughput.</li></ul><h4>Potential Solution 1: Google Function/ Serverless</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OwNRc6lMbDGe9vw93eILwQ.png" /><figcaption>Kubernetes cluster interfacing with a DB service and Google Function</figcaption></figure><p>I want to discuss this solution because image processing is a common use case for going <em>serverless</em>. Google Functions (AWS Lambda can also be considered, but we’re focusing on Google here — same idea) are a great way to handle this for some cases.</p><p>Here’s the general idea:</p><ol><li>Create an endpoint to receive the full size image and send to store.</li><li>Create a <a href="https://cloud.google.com/functions/docs/writing/background">background function</a> to handle image processing once it’s uploaded to the bucket.</li><li>Update persistent storage accordingly and send any other smoke signal that processing is complete.</li></ol><p>This is nice because it takes the heavy lifting off the core application and is quite scalable. However, there are some downsides — which may not effect you:</p><ul><li>The application will have to handle uploading the file to the storage bucket which requires you interfacing with Google’s GCP’s libraries and authorizing. When you’re dealing with many uploads, this can be a bottleneck. Alternatively, you can create a new public Lambda endpoint to accept the image, but you’ll have to also handle application level authentication there (if needed).</li><li>If you want to know when your processed images are ready you’ll have to create endpoints to consume the various update messages from the process.</li></ul><p>As you can see, this has the potential to become complicated due to all of the moving parts, especially if your application requires any level of user auth. This was not ideal for us.</p><h4>Potential Solution 2: Imageup Microservice</h4><p><a href="https://github.com/LevInteractive/imageup">Imageup</a> is a <a href="https://github.com/LevInteractive/imageup/blob/master/examples/k8s/imageup-deployment.yml#L6">replicable</a> http based microservice which can run privately within your network. It’s written in Go and makes use of the blazingly fast <a href="https://github.com/disintegration/imaging">Imaging</a> library. This allows for a synchronous way to send, process, and retrieve remote unique URL’s for images.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WulMbtgOYtsZW9eqi8JPcg.png" /><figcaption>Imageup within a Kubernetes cluster</figcaption></figure><p>The general idea for this is:</p><ol><li>Create an endpoint to handle authentication if needed and the file to upload.</li><li>Synchronously stream the file along with dimensions to imageup and receive a corresponding array of remote images ready to serve.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uJjGjafNFUPbRVyCNcqRTg.png" /><figcaption>request -&gt; payload</figcaption></figure><p>Kubernetes makes it easy to set this up, and you can deploy as many replicas as needed to handle concurrent processing. The key aspect for connectivity here, is that the Imageup service is using a private load balancer:</p><pre>metadata: <br>  name: imageup-service <br>  annotations:<br>    cloud.google.com/load-balancer-type: &quot;Internal&quot;</pre><p>From here, you’ll be able to interface with Imageup from your application. For us, it was from a node.js application using the interface module linked below. For more information, please checkout the <a href="https://github.com/LevInteractive/imageup/blob/master/docs/api.md">imageup API</a> and related resources below.</p><ul><li><a href="https://hub.docker.com/r/levinteractive/imageup/">Docker Repo</a></li><li><a href="https://github.com/LevInteractive/imageup/tree/master/examples/k8s">Kubernetes implementation example</a></li><li><a href="https://github.com/LevInteractive/imageup">Imageup Github Repo</a></li><li><a href="https://github.com/LevInteractive/imageup/blob/master/examples/node/imageup.js">Imageup node.js interface</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=df423d1b8ddd" width="1" height="1" alt=""><hr><p><a href="https://medium.com/stackahoy/image-processing-go-microservice-df423d1b8ddd">Image Processing as a Microservice</a> was originally published in <a href="https://medium.com/stackahoy">Stackahoy</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How and When to Use AWS Lambda Functions]]></title>
            <link>https://medium.com/stackahoy/migrating-to-aws-lambda-functions-c6977c56abe?source=rss----2ab958ee9680---4</link>
            <guid isPermaLink="false">https://medium.com/p/c6977c56abe</guid>
            <category><![CDATA[faa]]></category>
            <category><![CDATA[deploying-lambda]]></category>
            <category><![CDATA[functions-as-a-service]]></category>
            <category><![CDATA[aws-lambda-deployment]]></category>
            <category><![CDATA[aws-lambda]]></category>
            <dc:creator><![CDATA[Pete Saia]]></dc:creator>
            <pubDate>Tue, 12 Sep 2017 13:52:24 GMT</pubDate>
            <atom:updated>2017-09-12T15:53:28.495Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*srsdlzDvhDlv7Ik6dxAktg.jpeg" /><figcaption>A deep metaphor describing cloud-based resources.</figcaption></figure><p>Ephemeral cloud-based functions like <a href="http://docs.aws.amazon.com/lambda/latest/dg/welcome.html">AWS Lambda</a> and <a href="https://cloud.google.com/functions/">GCE Functions</a> are gaining traction quickly. If done right, they can be economically beneficial and enable infinite scalability™ without forcing you to wade into <a href="https://kubernetes.io/">swarms of containers</a>. If applied incorrectly, they can result in a much more expensive, over-engineered, and difficult to manage application. It’s important to understand that it isn’t all or nothing. Serverless is <em>in</em> our future, but it isn’t our exclusive future.</p><p>Functions as a service (FaaS) are functions configured in a cloud provider with a single entry point which lay dormant until triggered. Planning for FaaS is similar to the way you would approach learning about immutable objects, functional programming paradigms, or migrating from monolithic to distributed architectures. You break apart, simplify, and do an overall re-think of the application. However, it doesn’t mean you need to completely re-build the application.</p><h4>Banana for scale</h4><p>Say you have an existing monolithic application which acts as a tiling server — one similar to what Google or Mapbox uses to generate their beautiful jpg/png/json tiles.</p><p>The application’s core features are:</p><ol><li>Allow authenticated users to submit new geographical data to be processed and ultimately translated to tiles via <a href="https://github.com/mapnik/mapnik">Mapnik</a>. (Mapnik is common cartographic imaging software for processing things like Shape Files)</li><li>Serve tiles via HTTP — /{tile}/{zoom}/{lat}/{lng}.png</li><li>Allow for a special URL to generate a large map based on a bound box — /map/{north}/{south}/{east}/{west}/{zoom}.png</li></ol><p>It takes a lot of CPU to generate tens of thousands of tiles. If you want a performant application, you’ll be putting a substantial amount of your budget in GCE or AWS for VMs. You also have to consider handling more requests than a typical application. Generally, one page load will result in six or more tile requests, or whatever it takes to fill the screen. Dragging the map around quickly results in a lot more. A lot of people doing the same thing… well, you get the idea. A lot of requests.</p><p>Your initial build or <a href="https://en.wikipedia.org/wiki/Minimum_viable_product">MVP</a> may look something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tDo-FQimFBvyDgAk6wTs9A.png" /><figcaption>Monolithic Approach</figcaption></figure><p>This may work great at first. You could write background “tile warming” scripts which cache tiles before they get requested and other small enhancements to get a proof of concept out.</p><p>But what about when it’s time to scale? You could implement a microservice approach with tools such as Docker, Kubernetes, Packer and terraform. This would ultimately distribute the traffic and computing across more VMs. However, you’ll still be presented with two pain points:</p><ol><li>You’re limited to the technical bounds of the server specs until auto-scaling takes effect (assuming auto-scaling is setup). Not a reasonable thing for mission critical maps.</li><li>You must allocate the resources necessary ahead of time to accommodate your largest spike to avoid a crash. Obviously, this could be very costly.</li></ol><p>Rather than throwing money at the problem, this would be an appropriate time to leverage the power of Lambda functions.</p><p>Let’s make some fair assumptions.</p><ul><li>Mapnik processing and tile serving is our bottleneck, especially if tiles aren’t pre-cached upon request (more likely at higher zoom levels).</li><li>Tiles aren’t getting processed or served 100% of the time. For instance, in the middle of the night or after all tiles have been warmed (cached) for a specific layer.</li><li>The admin area is a single-page javascript app which interfaces with a simple API via OAuth2 authentication. This API does not get nearly as much traffic as the tiling server. Basically, it’s a simple web app.</li></ul><p>Based on this information, we could break up the application in the following way:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p3J1adwAF8nR4yzjB-iG4A.png" /><figcaption>FaaS Approach</figcaption></figure><p>By breaking out the tiling server and tile generator, our VM instance for the base client application becomes much simpler and requires minimal resources. We could probably get away with a standard size VM for this.</p><p>Last but not least, costs will be kept in check, making the common adage “if we need to scale, that’s going to be a good problem!” more true to the usage-to-cost curve.</p><h4>Application Structure</h4><p>Breaking out specific services in your application will create more moving parts, thus creating more complexity. To help relieve this, we built functionality within <a href="https://stackahoy.io/">Stackahoy</a> (our continuous deployment SaaS tool) to allow for directory-specific lambda packaging so you won’t have to manage this independently.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bCjN8NgNdxeqxPit5eDsuA.png" /><figcaption>Unobtrusive Directory to Lambda Packaging</figcaption></figure><p>Using the directory to function mapping feature, you can simply point to a directory that should be exported. Stackahoy will then create the package (zip file) and update the function within your AWS account. Meanwhile, any other more “traditional” Docker or file-based deployment will happen at the same time.</p><p>Alternatively, you could build a fully serverless application in one repo without any other type of deployment enabled.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wCsT7ZvQamAC5eOFg4A8vw.png" /></figure><h4>Conclusion</h4><p>FaaS is by no means a magic fix for everything but, if used appropriately, it can be an incredibly powerful and cost saving tool.</p><p>Here are some useful links for further reading:</p><ul><li><a href="https://softwareengineeringdaily.com/2017/05/22/microservices-transition-with-cassandra-shum/">This podcast with Cassandra Shum describes some helpful strategies for migrating to microservices. These strategies can also be applied to FaaS.</a></li><li><a href="https://aws.amazon.com/documentation/lambda/">AWS Lambda documentation</a></li><li><a href="https://cloud.google.com/functions/docs/">GCE Functions documentation</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c6977c56abe" width="1" height="1" alt=""><hr><p><a href="https://medium.com/stackahoy/migrating-to-aws-lambda-functions-c6977c56abe">How and When to Use AWS Lambda Functions</a> was originally published in <a href="https://medium.com/stackahoy">Stackahoy</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Continuous Delivery Archetypes]]></title>
            <link>https://medium.com/stackahoy/continuous-delivery-archetypes-b692c63b05a5?source=rss----2ab958ee9680---4</link>
            <guid isPermaLink="false">https://medium.com/p/b692c63b05a5</guid>
            <category><![CDATA[continuous-integration]]></category>
            <category><![CDATA[docker-deployment]]></category>
            <category><![CDATA[continuous-deployment]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[continuous-delivery]]></category>
            <dc:creator><![CDATA[Pete Saia]]></dc:creator>
            <pubDate>Wed, 30 Aug 2017 12:38:18 GMT</pubDate>
            <atom:updated>2017-09-12T14:03:43.200Z</atom:updated>
            <content:encoded><![CDATA[<p>The purpose of this article is to highlight some of the most common and bulletproof deployment strategies (we’ll be using <a href="https://stackahoy.io/">stackahoy.io</a> here).</p><p>We’ll cover:</p><ol><li><a href="#b243">Basic Filesystem Deployment Pipeline</a></li><li><a href="#1b20">Filesystem w/ CI Deployment Pipeline</a></li><li><a href="#5966">“Atomic” Strategy</a></li><li><a href="#2441">Configuration File Strategies</a></li><li><a href="#713c">Docker Deployment</a></li></ol><h3><strong>Basic Filesystem Deployment Pipeline</strong></h3><p>While this is the most basic type of deployment, it’s also the fastest to deploy and easiest to setup. This is a common setup for shared environments — generally LAMP stack applications on one or more servers. Think WordPress, Drupal, etc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5ayddNUKE3xyY5-0LeRyVw.png" /><figcaption>Basic Filesystem Deployment Pipeline Diagram</figcaption></figure><p><strong>Overview:</strong></p><ul><li>The quickest delivery possible (usually less than a second).</li><li>Cache/configuration files are placed in the .gitignore file so they are ignored and not removed on each deployment.</li><li>Third-party dependencies are never stored in the repository.</li><li>Configuration files are .gitignore’d and securely stored in Stackahoy as dynamic static files.</li><li>Load balancer w/ concurrent deployment capable.</li></ul><h3>Filesystem w/ CI Deployment Pipeline</h3><p>This is almost identical to the first pipeline flow, except with a proper continuous integration pipeline. This is obviously the ideal approach so the engineering team can rest easy knowing broken code isn’t being deployed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vyZ-CgsE8sil5fcN1DYhNw.png" /><figcaption>Filesystem w/ CI Deployment Pipeline Diagram</figcaption></figure><p><strong>Overview:</strong></p><ul><li>CI software such as <a href="https://travis-ci.org/">Travis</a>, <a href="https://circleci.com/">Circle</a>, or <a href="https://about.gitlab.com/features/gitlab-ci-cd/">GitLab</a> is required.</li><li>Once the CI pipeline completes successfully, it can use the <a href="https://stackahoy.io/docs/command-line">Stackahoy CLI</a> tool to trigger the deployment. This keeps your CI <a href="https://en.wikipedia.org/wiki/Don%27t_repeat_yourself">DRY</a> and decoupled from any server authentication or handshakes. If it’s a docker runner, you can just use the official <a href="https://hub.docker.com/r/stackahoy/stackahoy-cli/">Stackahoy docker container</a> instead of installing the CLI tool explicitly.</li><li>Load balancer w/ concurrent deployment capable.</li></ul><h3>“Atomic” Strategy</h3><p>While Stackahoy’s file delivery mechanism is almost instant due to its diff algorithm, the span of time during the deployment is a moment of instability and uncertainty. This time especially increases when there are post-deployment commands building frontend assets.</p><p>A viable solution is to implement “atomic” deployments. The term atomic basically means updates resolve only resolve when the deployment is 100% complete.</p><p>This deployment can be setup in three steps:</p><p><strong>Step One | Directory Structure</strong></p><p>Provision your destination server with the following structure. <strong>Make sure the user you’re deploying as has read/write permissions on these directories.</strong></p><pre>./.tmp<br>./live-app<br>./archives</pre><p><strong>Step Two | Web Root</strong></p><p>Setup your web server (nginx, apache, ect.) to make ./live-app the web root. This will be the “hot” directory.</p><p><strong>Step Three | Configure Deployment Delivery</strong></p><p>Within Stackahoy, setup the <em>Remote Working Directory</em> to be ./.tmp. This will cause your deployment to happen discreetly without effecting what’s in the live directory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h5tx3UqirqwlxXkMWIaIww.png" /><figcaption>Atomic Delivery Diagram</figcaption></figure><p>Now, here is where the magic happens. Place the following post-deployment commands in Stackahoy:</p><pre>f=$(date +%Y-%m-%d-%H-%M-%S)<br>dest=$(realpath $(pwd)/..)</pre><pre># Archive newly deployed files in the releases directory.<br>cp -R $dest/.tmp/ $dest/releases/$f</pre><pre># Update the symlink to point to the latest release (atomic).<br>ln -sfn $dest/releases/$f $dest/live-app</pre><pre># Clean up.<br>rm -rf $dest/.tmp/*</pre><p>Note: This assumes any cache directories or resources which need to persist are kept outside of the working directory.</p><p>If your application requires these types of resources, a little extra work will be required in order to update the paths to the directories. This method also requires a little more disk space on your destination server since you’ll be storing previous releases. The upside is that at any point in time the codebase can be reverted to a previous release. Essentially, you get cheap version control.</p><h3>Configuration File Strategies</h3><p>There is no shortage of libraries in any language to handle the configurations for an application. When considering a production environment, the following should be true:</p><ul><li>Sensitive credentials/keys should not be stored in any repository.</li><li>The environment should be replicable (e.g. DRY, immutable).</li><li>These sensitive items should be maintained in one place.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mZ16ezbe5vbYyoD2w46Ihg.png" /></figure><p>We recommend the one of the following strategies for handling this:</p><ol><li><strong>Immutable configuration files:</strong> By using Stackahoy’s encrypted dynamic configuration files feature, files are destroyed and created on every deployment. This also works great for Docker Deployments, since you can just volume the dynamic configuration file to the running container.</li><li><strong>Environmental Variables:</strong> This method is dependent on your hosting provider and/or other SaaS products. Some potential solutions are: <a href="https://aws.amazon.com/kms/">AWS Key store</a>, setting environmental variable in GCE</li></ol><h3>Docker Deployment</h3><p>This is by far the most popular and powerful deployment pipeline. First take a look at the diagram, and we’ll break it down.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0tQhh62N57skMYi_LmWSFQ.png" /><figcaption>Docker Deployment Pipeline Diagram</figcaption></figure><p>This deployment requires a CI runner and a Docker registry. In a nutshell, the runner will test the code, build the image, then upload the image to the registry.</p><p>Stackahoy makes it easy to decouple and trigger the deployment by using the Stackahoy CLI tool. Here is a snippet from the deployment stage of a GitLab CI pipeline:</p><pre>deploy:<br>  image: stackahoy/stackahoy-cli<br>  stage: deploy<br>  script:<br>    - stackahoy deploy -b production -r $REPO_ID -t $STACKAHOY_TOKEN<br>  only:<br>    - production</pre><p>In a single line we are using the official <a href="https://hub.docker.com/r/stackahoy/stackahoy-cli/">stackahoy/stackahoy-cli image</a> to run the command so we don’t have to manually install the tool. Alternatively, you could just npm i -g stackahoy-cli.</p><p>If you’re using <a href="https://docs.docker.com/compose/">docker-compose</a>, a simple way to handle the actual deployment is to just run the following post-deployment commands:</p><pre># Pull the latest image that was created in the registry.<br>docker-compose pull</pre><pre># (Re)create any changed containers.<br>docker-compose up -d</pre><p>Alternatively, you could be initiating <a href="https://docs.docker.com/engine/swarm/">Docker Swarm</a>, a bash script or <a href="https://kubernetes.io/">Kubernetes</a> for this stage.</p><h3>Summary</h3><p>This is a living and breathing document and will be updated with the rapidly evolving technology. Stay tuned for new serverless (Lamba &amp; GCE Functions) features coming soon to Stackahoy as well!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b692c63b05a5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/stackahoy/continuous-delivery-archetypes-b692c63b05a5">Continuous Delivery Archetypes</a> was originally published in <a href="https://medium.com/stackahoy">Stackahoy</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Lean and Powerful Automated Deployments for Cloud Based Web Applications]]></title>
            <link>https://medium.com/stackahoy/deploying-web-applications-for-web-agencies-fd2882df2007?source=rss----2ab958ee9680---4</link>
            <guid isPermaLink="false">https://medium.com/p/fd2882df2007</guid>
            <category><![CDATA[continuous-deployment]]></category>
            <category><![CDATA[deployment]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[continuous-integration]]></category>
            <category><![CDATA[continuous-delivery]]></category>
            <dc:creator><![CDATA[Pete Saia]]></dc:creator>
            <pubDate>Sat, 26 Aug 2017 16:04:18 GMT</pubDate>
            <atom:updated>2017-04-22T14:38:02.584Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PVEUIF6KJAdoCc98IVpUDg.jpeg" /></figure><p>When we started <a href="http://lev-interactive.com/">Lev</a> two years ago, we faced a decision that companies and organizations of all stripes need to deal with — deployments. There is a seemingly infinite number of setups but, in our view, all options seem to fall short in one way or another. When putting together a wish list for our ideal automated deployment solution, here’s what we came up with:</p><ul><li>Manage config files in one place for applications. (Environment specific files like wp-config.php, production.rb, ect.)</li><li>Securely maintain both our open source and our client’s deployments under one roof. No need to mess with a configuration files or connecting wires for each new project.</li><li>Deploy to any SSH-capable Linux server, including shared hosting environments.</li><li>Parallel multi-server delivery.</li><li>Repository-specific deploy keys. Ideal for Git providers that require unique deploy keys. In our case, GitHub and GitLab.</li><li>Post-deployment commands for building/compiling our applications right on the server. Useful for building docker images, compiling assets or restarting services.</li><li>Incredibly fast and secure file migration with only SSH (not relying on FTP or FTPS).</li><li>No server dependencies needed for deployment. Not even Git.</li><li>The ability to intelligently deploy while respecting the .gitignore file so nothing gets blown out.</li></ul><p>So we took it upon ourselves to write a low level node.js script which handled <a href="https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks#Server-Side-Hooks">Git post-receive</a> payloads. After some tweaking it worked great. Success, right? Well, almost. We had achieved our goal of automated deployments, but the solution was cobbled together using too many tools and providers, and fell short of the all-in-one-place requirement. We needed to manually configure a post-receive hook in whatever repository we were deploying (GitHub or GitLab), and for post-commands we needed to create one-off bash scripts. Not ideal. We needed a user interface.</p><p>… So <a href="https://stackahoy.io/">Stackahoy</a> was born.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A1Rf-lS9ZW0EzrRaAL7n5A.jpeg" /></figure><p>We now use Stackahoy for all deployments (including Stackahoy itself) and we’re inviting you to check it out <a href="https://stackahoy.io/">for free</a>. Below you can see the proposed anatomy of a project workflow with the help of Stackahoy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ozWjdTJSejmYWJ9-Xn4K8Q.jpeg" /></figure><p>Instead of using one service to handle everything, Stackahoy allows you to work with other great services for things like testing and issue tracking while unobtrusively handling automated deployments. The end result is a lean and non-restrictive development environment. Enjoy!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fd2882df2007" width="1" height="1" alt=""><hr><p><a href="https://medium.com/stackahoy/deploying-web-applications-for-web-agencies-fd2882df2007">Lean and Powerful Automated Deployments for Cloud Based Web Applications</a> was originally published in <a href="https://medium.com/stackahoy">Stackahoy</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JavaScript compiling: An argument to reinvent the wheel.]]></title>
            <link>https://medium.com/stackahoy/javascript-compiling-an-argument-to-reinvent-the-wheel-b6ec93252acf?source=rss----2ab958ee9680---4</link>
            <guid isPermaLink="false">https://medium.com/p/b6ec93252acf</guid>
            <category><![CDATA[grunt]]></category>
            <category><![CDATA[gulp]]></category>
            <category><![CDATA[webpack]]></category>
            <category><![CDATA[application-development]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Pete Saia]]></dc:creator>
            <pubDate>Sat, 26 Aug 2017 16:02:39 GMT</pubDate>
            <atom:updated>2017-09-04T20:12:34.140Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OYw9yCTxPVR7pxxhTu6Jgg.jpeg" /></figure><p>Gone are the days when concatenating and <a href="https://github.com/mishoo/UglifyJS">uglifying</a> your source code was sufficient. With <a href="http://www.ecma-international.org/ecma-262/6.0/">es6</a> and <a href="https://www.ecma-international.org/ecma-262/7.0/">es7</a> developing more rapidly than browser vendors can keep up with, <a href="https://www.typescriptlang.org/">typescript</a> and <a href="https://flow.org/">flow</a> type checking, and <a href="https://facebook.github.io/relay/docs/guides-babel-plugin.html">other</a> <a href="http://sass-lang.com/">aberrant</a> <a href="http://jescalan.github.io/rupture/">requirements</a> <a href="https://developers.google.com/closure/compiler/">your</a> <a href="http://eslint.org/">project</a> <a href="https://github.com/nodeca/js-yaml">may</a> <a href="https://github.com/arnauddri/npm-html2js">have</a>, the desire to use something to magically <em>pipe</em> and <em>bundle</em> in one fell swoop can be quite attractive. This leads us to build tools like <a href="https://webpack.github.io/">webpack</a>, <a href="https://gruntjs.com/">grunt</a>, and <a href="http://gulpjs.com/">gulp</a>. With a surgeon’s hand and an abundance of third-party modules you can carefully construct something that will spit out all of your assets with something like: gulp build.</p><p>Awesome. Right? At least for a few weeks until one of the dependencies deprecates|breaks and you need to upgrade and as soon as you know it’s 1 in the morning and you’ve been presented with infographics like this all night:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oB4JjK6aBjMJqL3V5g3AWQ.png" /><figcaption>that cube tho. but seriously…</figcaption></figure><p>So let’s unpack that (pun intended). These node automators are a third layer of abstraction on top of the actual utilities which do the heavy lifting. The strength of the glue which holds these two layers together is at the mercy of a developer or developers who may or may not be doing their best to pay attention to the developers who maintain the utilities in which they interface. The glue will break after a while unless you’ve got your eye on all of these layers. Even when vigilant, you probably won’t have a good time.</p><p>There are an increasing number of people frustrated with the vibrant JavaScript/node community because of the amount of new toolings being created every day. I believe the real frustration starts with how these tools are integrated.</p><p>So how can we make this better? I’d like to propose a stronger and more standalone approach:</p><ul><li><strong>Don’t pollute your actual project’s package.json with build related modules.</strong> Any of them — browserify, babel, sass, ect. Even if you’re good about keeping them in devDependencies. Keep your project in a clean state in a src/ folder. At the root, keep another package.json file which holds any build or development related modules. What needs to be compiled today, may run native (or change) tomorrow so it’s best to decouple that dependency.</li></ul><pre>- /package.json     &lt;- only dev deps<br>- /src/package.json &lt;- only application deps<br>- /src/*            &lt;- the rest of the project</pre><ul><li><strong>A wheel for automation has been around for a long time.</strong> Make use of bash, shell, and Makefiles. If you haven’t read it already, <a href="https://github.com/isaacs">isaacs</a> (creator of npm) wrote a <a href="https://gist.github.com/isaacs/62a2d1825d04437c6f08">great intro to Makefiles</a>. This will allow you to interface with the utilities directly, not through something like webpack, gulp, or grunt. Upsides: 1) You will always use 100% of the options available to you without relying on the maintainers to update the master branch because you’re using the actual program — not an interface to it. 2) This also avoids that third layer of abstraction — the weak glue.</li></ul><p>Lastly, I’ll leave you with some inspiration for actually executing on this in the form of a git repository, <a href="https://github.com/petesaia/node-native-task-runner">here</a>.</p><p>So how about we not try to automate all the things with one thing?</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b6ec93252acf" width="1" height="1" alt=""><hr><p><a href="https://medium.com/stackahoy/javascript-compiling-an-argument-to-reinvent-the-wheel-b6ec93252acf">JavaScript compiling: An argument to reinvent the wheel.</a> was originally published in <a href="https://medium.com/stackahoy">Stackahoy</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A guide to automated Docker deployments w/ GitLab CI]]></title>
            <link>https://medium.com/stackahoy/a-guide-to-automated-docker-deployments-w-gitlab-ci-510966dd6022?source=rss----2ab958ee9680---4</link>
            <guid isPermaLink="false">https://medium.com/p/510966dd6022</guid>
            <category><![CDATA[continuous-integration]]></category>
            <category><![CDATA[gitlab-ci-docker]]></category>
            <category><![CDATA[gitlab]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[docker-deployment]]></category>
            <dc:creator><![CDATA[Pete Saia]]></dc:creator>
            <pubDate>Sat, 26 Aug 2017 15:55:29 GMT</pubDate>
            <atom:updated>2017-07-10T20:28:45.259Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GVHVg7Dw5zE1xLzx6YmRoA.jpeg" /><figcaption>Because shipping with Docker needs a nautical theme.</figcaption></figure><blockquote>This article assumes you are using (or interested in using) GitLab and GitLab CI. While the following explains how to deploy Docker containers, it can easily be adjusted to accommodate any type of project. Feel free to post any questions in the comments section below.</blockquote><h3>Objectives</h3><ol><li>Once the production branch (or any branch we’re interested in) is pushed, have the runner build our application’s Docker container.</li><li>Once the container is built, push to our project’s <a href="https://about.gitlab.com/2016/05/23/gitlab-container-registry/">GitLab private container registry</a>.</li><li>Deploy the container to our production server using the (free) <a href="https://stackahoy.io/docs/cli">Stackahoy command-line tool</a>. As a disclaimer, we built <a href="https://stackahoy.io/">Stackahoy</a> and have been using it internally for a few years.</li></ol><h3><strong>Step 1: Create a runner.</strong></h3><p>GitLab CI runners are decoupled from the core GitLab CI instance and serve as the workhorses for testing, building, and deploying an application. We are using GitLab’s <a href="https://gitlab.com/gitlab-org/gitlab-ci-multi-runner/">Multi-runner</a> on a small <a href="https://cloud.google.com/compute/">Google Compute Engine</a> instance.</p><p>Follow the steps <a href="https://gitlab.com/gitlab-org/gitlab-ci-multi-runner/blob/master/docs/install/linux-repository.md">here</a> for installing the runner in your desired environment, then run:</p><pre># Make sure to replace REG_TOKEN and/or the <br># --url to match your environment.</pre><pre>sudo gitlab-ci-multi-runner register \<br>  -n \<br>  --url <a href="https://dev.lev-interactive.com/ci">https://p</a>ath-to-github.com/ci \<br>  --tag-list &quot;docker&quot; \<br>  --registration-token REG_TOKEN \<br>  --executor docker \<br>  --description &quot;Docker Runner&quot; \<br>  --docker-image &quot;docker:latest&quot; \<br>  --docker-volumes /var/run/docker.sock:/var/run/docker.sock</pre><p>As of writing this article, there are three ways of using the “docker” command within our runner container. You can read about them <a href="http://docs.gitlab.com/ce/ci/docker/using_docker_build.html#runner-configuration">here</a>. We chose to volume the docker.sock file.</p><h3>Step 2: Configure gitlab-ci.yml.</h3><p>The gitlab-ci.yml file should be placed in the root of the project. This contains instructions used by GitLab CI.</p><p>.gitlab-ci.yml:</p><pre>variables:<br>  REGISTRY: your-gitlab-server:4567<br>  REPO_ID: 574535091c632d0d00f646cc</pre><pre>stages:<br>  - build<br>  - deploy</pre><pre>build:<br>  image: docker:latest<br>  stage: build<br>  script:<br>    - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $REGISTRY<br>    - docker build -t $REGISTRY/&lt;PROJECT-GROUP&gt;/&lt;PROJECT-NAME&gt; .<br>    - docker push $REGISTRY/&lt;PROJECT-GROUP&gt;/&lt;PROJECT-NAME&gt;<br>  only:<br>    - production<br>  tags:<br>    - docker</pre><pre>deploy:<br>  image: stackahoy/stackahoy-cli<br>  stage: deploy<br>  script:<br>    - stackahoy deploy -t $STACKAHOY_TOKEN -b production -r $REPO_ID --skip-delivery<br>  only:<br>    - production<br>  tags:<br>    - docker</pre><p>Let’s break the file down.</p><pre>variables:<br>  REGISTRY: your-gitlab-server:4567<br>  REPO_ID: 574535091c632d0d00f646cc</pre><p>Here we define two variables which are used later in the file. This is simply to make the file more readable and reusable for other projects. <em>REGISTRY</em> is the URL for the private GitLab container registry. <em>REPO_ID</em> is the Stackahoy repository ID — you will retrieve this from the repository URL for the landing page within Stackahoy — <a href="https://stackahoy.io/group/"><em>https://stackahoy.io/group/</em></a><strong>&lt;repo-id&gt;</strong><em>/</em>.</p><pre>stages:<br>  - build<br>  - deploy</pre><p>The stages property simply allows you to define the order in which the jobs should be executed. In this instance, the jobs are “build” and “deploy”. You could name these anything you’d like. Generally, you’d have a “test” job as well to handle your functional and unit tests and maybe a specific job for building a staging container.</p><pre>build:<br>  image: docker:latest<br>  stage: build<br>  script:<br>    - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $REGISTRY<br>    - docker build -t $REGISTRY/&lt;PROJECT-GROUP&gt;/&lt;PROJECT-NAME&gt; .<br>    - docker push $REGISTRY/&lt;PROJECT-GROUP&gt;/&lt;PROJECT-NAME&gt;<br>  only:<br>    - production<br>  tags:<br>    - docker</pre><p>The “build” job does two things. First, it will build the Docker container. Second, it will push the container to the private GitLab registry.</p><p>The last thing I’ll note about this snippet is the user that docker logs in as — gitlab-ci-token. This is a special user which is meant to be used with the variable <em>$CI_BUILD_TOKEN</em>. This variable will be defined on any GitLab CI build. This is much cleaner and safer than using your personal credentials for GitLab. The <em>&lt;PROJECT-GROUP&gt;/&lt;PROJECT-NAME&gt;</em> should be set based on the name of the project’s group and name, respectively.</p><pre>deploy:<br>  image: ubuntu:latest<br>  stage: deploy<br>  script:<br>    - apt-get update<br>    - apt-get install -y -qq npm curl<br>    - npm install -g n<br>    - n stable<br>    - npm install -g stackahoy<br>    - stackahoy deploy -t $STACKAHOY_TOKEN -b production -r $REPO_ID --skip-delivery<br>  only:<br>    - production<br>  tags:<br>    - docker</pre><p><strong>Update (July 2017):</strong> Now you can use the new <a href="https://hub.docker.com/r/stackahoy/stackahoy-cli/">Stackahoy CLI</a> docker container to speed this up. Doing so would look like this:</p><pre>deploy:<br>  image: stackahoy/stackahoy-cli<br>  stage: deploy<br>  script:<br>    - stackahoy deploy -t $STACKAHOY_TOKEN -b production -r $REPO_ID --skip-delivery<br>  only:<br>    - production<br>  tags:<br>    - docker</pre><p>Finally, we’re at the deployment. In order to deploy, we can use Stackahoy which actually handles the secure transfer of files from the repository to the staging or production server. In our case, we’re not transferring files (note the --skip-delivery flag) and only running the docker run commands on the server since the container is already built.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NE81p4diiV96B5Xs7evT7Q.jpeg" /><figcaption>Stackahoy Repository Configuration Page</figcaption></figure><p>One really cool feature in GitLab is it allows us to define variables in the project’s settings so we don’t have to commit them to the repository. This is where the <em>$STACKAHOY_TOKEN</em> variable is being set. This special token is obtained from the Stackahoy dashboard and allows the stackahoy command to deploy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3zMLAvvCATtHUShivpgnUQ.png" /><figcaption>GitLab Project Admin — Variables</figcaption></figure><h3>Step 3: Deploy.</h3><p>Stackahoy takes care of the work on the destination server. This work includes:</p><ul><li>Syncing files (taking .gitignore file in account) to our server(s).</li><li>Running/restarting Docker containers.</li><li>Delivering static configuration files.</li><li>Building assets, clearing cache, db migrations, ect.</li></ul><p>For this setup, we’ll be starting up a MongoDB container using the <a href="https://hub.docker.com/_/mongo/">public Mongo image</a> from the Docker hub and running the container we just built in the “build” stage. The Stackahoy post-commands will look like the following:</p><pre># Start up mongo container.<br>docker run --name my-mongo -d mongo</pre><pre># Login to private registry.<br>docker login -u gitlab-ci-token -p [token-here] [url-here]</pre><pre># Run app and link mongo.<br>docker run \<br>  --name my-app \<br>  -p 80:80 \<br>  -e &quot;NODE_ENV=production&quot; \<br>  --link my-mongo:mongo \<br>  -d [url-here]</pre><p>The “--skip-delivery” flag in the gitlab-ci.yml file tells Stackahoy to only run these commands and not to worry about file syncing which keeps deployments lean and to the point.</p><h3>Conclusion</h3><p>A real world application will likely have a few more jobs such as various testing and at least one more container build in the .gitlab-ci.yml file, but this should provide a solid starting point for your project.</p><h4>Useful links</h4><ul><li><a href="http://docs.gitlab.com/ce/ci/docker/using_docker_build.html">Building Docker based projects</a></li><li><a href="http://docs.gitlab.com/ce/ci/examples/test-and-deploy-python-application-to-heroku.html">Deploying a Heroku application</a></li><li><a href="http://docs.gitlab.com/ce/ci/">GitLab CI Docs</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=510966dd6022" width="1" height="1" alt=""><hr><p><a href="https://medium.com/stackahoy/a-guide-to-automated-docker-deployments-w-gitlab-ci-510966dd6022">A guide to automated Docker deployments w/ GitLab CI</a> was originally published in <a href="https://medium.com/stackahoy">Stackahoy</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>