Atomic Deployment for JS Hipsters

Rate this content
Bookmark

Deploying an app is all but an easy process. You will encounter a lot of glitches and pain points to solve to have it working properly. The worst is: that now that you can deploy your app in production, how can't you also deploy all branches in the project to get access to live previews? And be able to do a fast-revert on-demand?

Fortunately, the classic DevOps toolkit has all you need to achieve it without compromising your mental health. By expertly mixing Git, Unix tools, and API calls, and orchestrating all of them with JavaScript, you'll master the secret of safe atomic deployments.

No more need to rely on commercial services: become the perfect tool master and netlifize your app right at home!

This talk has been presented at DevOps.js Conf 2024, check out the latest edition of this Tech Conference.

FAQ

In atomic deployment, you take two versions of an existing application and deploy only the changes between these two versions. Everything is self-contained, allowing you to take a whole archive of a version at any point in time without worrying about dependencies or build processes.

Netlify simplifies deployment by automatically deploying changes pushed to a branch on your version server, like GitHub. You get instant previews on staging URLs, and updates to branches automatically update the previews, making deployment a seamless process.

The key features include configurability for easy adaptation to different projects, compatibility with any hosting provider, integration with micro-CI for handling dependencies and builds, minimal downtime during deployment, and auto-publishing to update previews automatically.

Matt is a Developer Experience Engineer at Always Data, an independent hosting provider. He focuses on improving developer experience, particularly on the CLI and tools associated with the platform.

You configure a project for atomic deployment by initializing a bare repository on the server, linking it to your local project, and setting configuration variables using Git config. The deployment process is automated through Git hooks, specifically the post-receive hook.

Git hooks allow you to react to events in the Git repository's lifecycle. The post-receive hook is particularly useful for deployment as it triggers actions like building and deploying the application each time changes are pushed.

Hard links are used to copy only the changed files between versions, improving performance and maintaining self-containment. This ensures that each version of the application is complete and standalone without duplicating the entire content.

SSH remote access is crucial as it allows secure interaction with the server for tasks like initializing repositories, configuring projects, and automating deployments through Git hooks.

Yes, webhooks can be used to automate the process of pushing changes from the origin remote to the deploy remote, reducing friction and improving the developer experience.

Keep the process simple and maintainable by using Git config for storing variables, abstracting web hosting changes through API calls, and leveraging Node.js or Deno as CI engines for build processes. This ensures a smooth and adaptable deployment workflow.

m4dz
m4dz
25 min
15 Feb, 2024

Comments

Sign in or register to post your comment.

Video Summary and Transcription

This Talk discusses atomic deployment for JavaScript and TypeScript, focusing on automated deployment processes, Git hooks, and using hard links to copy changes. The speaker demonstrates setting up a bare repository, configuring deployment variables, and using the post-receive hook to push changes to production. They also cover environment setup, branch configuration, and the build process. The Talk concludes with tips on real use cases, webhooks, and wrapping the deployment process.

1. Introduction to Atomic Deployment

Short description:

We're going to talk about atomic deployment for JavaScript and TypeScript Hipsters. In an atomic deployment, you take two versions of an existing application and deploy the changes between them. It's self-contained and eliminates the need to worry about dependencies and building. The goal is to have a functional, workable, and compatible solution with a simple developer experience.

Hi, folks. Welcome to this talk for us, DevOps JS Conference. We're going to talk about atomic deployment for JavaScript and TypeScript Hipsters.

Right before starting, a little bit of information about what atomic deployment and immutable deployment are. In an atomic deployment, you take two versions of an existing application and you're just deploying the changes between these two versions, but everything is self-contained. So you can take a whole archive of version at any point of time and everything is self-contained and you don't have to worry about anything about that. This is what makes Netlify so successful in the past because suddenly you just had to push a branch on your version server like GitHub or whatever, and it was automatically deployed on your production server in a staging URL like mybranch slash myapp.mydomain.com.

So it's really powerful because you just have to push some changes in any kind of branch, you automatically have a lot of previews directly accessible. And each time you update your branch like updating your PR, the preview updates itself as the same way. So it's definitely useful, especially when deployment is a painful process when you have to worry about dependencies and building and so on. So what is the hipster ways to do these kind of atomic or immutable deployments?

My idea is that I want to keep it working. I want to stick to this principles of atomic and immutable deployments. I want it to be functional, workable, and compatible with any hosting provider, whichever it was. And I want to stick to the simple developer experience. Like, I just want to push my branch and my preview is automatically deployed or updated, and that's all. And I don't care about how to use it and how to work with it and so on. So what are the expected features on these ones specifically?

So I want it to be configurable because I don't want to revamp the whole process for each project. I want to have some things that is easily deployable to any kind of repository and where I just have to tweak a few variables to configure it for this very specific project at a time. I want it to be band-lasting compatible, so working on any kind of hosting provider in the wild. I want some kind of micro-CI integrated like deployment dependencies and building and so on. Everything handled by the solution by itself. So I don't have to worry about anything about that. But without the tests you eat and so on, it doesn't care. I want no too minimal downtime on deployment to keep it really working. So I don't want to break something on the production just because I pushed a brand that suddenly didn't build or something else. So I want some kind of safeguards at some points to be sure that nothing can be down at some point. And I want it to be auto-publishable. So I just want to push it in a branch and boom, my branches, my preview associated to my branch is automatically updated. So I'm Matt, folks. I'm a developer experience engineer at Always Data, which is a hosting provider, an independent one.

2. Setting Up Automated Deployment

Short description:

I will show you the foundation of our automated deployment process with atomic and immutable deployment features. We will work on the server, have the web hosts and repositories in the same place, and rely on SSH remote access. I'll initialize a bare repository and link it to a new application.

So my responsibility at Always Data is working on the developer experience, most specifically on the CLI and the tools associated with the platform itself. What I will show you is the foundation of our automated deployment process with atomic and immutable deployment features. It's currently in development in CLI, but it will be available soon. I'm excited to share it with you because it's the result of my search. Let's dive into the code to see it in action.

For this talk, we will work on the server, whether it's a container, VPS, or bare metal. The idea is to have the web hosts and repositories responsible for atomic deployment in the same place. We will rely heavily on SSH remote access. Webhooks are not part of this talk, but I'll briefly mention them in the conclusion.

To get started, I'll SSH directly onto the server in my container with my hosting account. I'll ensure that I'm in the /var folder, where the www folder is located. This is the document root for our web server engine. I'll initialize a bare repository in /var/repo. A bare repository contains only the Git elements and not the source code itself. Back on my local computer, I'll create a new application and link it to the repository in the container using SSH.

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

Levelling up Monorepos with npm Workspaces
DevOps.js Conf 2022DevOps.js Conf 2022
33 min
Levelling up Monorepos with npm Workspaces
Top Content
NPM workspaces help manage multiple nested packages within a single top-level package, improving since the release of NPM CLI 7.0. You can easily add dependencies to workspaces and handle duplications. Running scripts and orchestration in a monorepo is made easier with NPM workspaces. The npm pkg command is useful for setting and retrieving keys and values from package.json files. NPM workspaces offer benefits compared to Lerna and future plans include better workspace linking and adding missing features.
Remix Flat Routes – An Evolution in Routing
Remix Conf Europe 2022Remix Conf Europe 2022
16 min
Remix Flat Routes – An Evolution in Routing
Top Content
Remix Flat Routes is a new convention that aims to make it easier to see and organize the routes in your app. It allows for the co-location of support files with routes, decreases refactor and redesign friction, and helps apps migrate to Remix. Flat Folders convention supports co-location and allows importing assets as relative imports. To migrate existing apps to Flat Routes, use the Remix Flat Routes package's migration tool.
Automating All the Code & Testing Things with GitHub Actions
React Advanced Conference 2021React Advanced Conference 2021
19 min
Automating All the Code & Testing Things with GitHub Actions
Top Content
We will learn how to automate code and testing with GitHub Actions, including linting, formatting, testing, and deployments. Automating deployments with scripts and Git hooks can help avoid mistakes. Popular CI-CD frameworks like Jenkins offer powerful orchestration but can be challenging to work with. GitHub Actions are flexible and approachable, allowing for environment setup, testing, deployment, and custom actions. A custom AppleTools Eyes GitHub action simplifies visual testing. Other examples include automating content reminders for sharing old content and tutorials.
Fine-tuning DevOps for People over Perfection
DevOps.js Conf 2022DevOps.js Conf 2022
33 min
Fine-tuning DevOps for People over Perfection
Top Content
DevOps is a journey that varies for each company, and remote work makes transformation challenging. Pull requests can be frustrating and slow, but success stories like Mateo Colia's company show the benefits of deploying every day. Challenges with tools and vulnerabilities require careful consideration and prioritization. Investing in documentation and people is important for efficient workflows and team growth. Trust is more important than excessive control when deploying to production.
Why is CI so Damn Slow?
DevOps.js Conf 2022DevOps.js Conf 2022
27 min
Why is CI so Damn Slow?
Slow CI has a negative impact on productivity and finances. Debugging CI workflows and tool slowness is even worse. Dependencies impact CI and waiting for NPM or YARN is frustrating. The ideal CI job involves native programs for static jobs and lightweight environments for dynamic jobs. Improving formatter performance and linting is a priority. Performance optimization and fast tools are essential for CI and developers using slower hardware.
End the Pain: Rethinking CI for Large Monorepos
DevOps.js Conf 2024DevOps.js Conf 2024
25 min
End the Pain: Rethinking CI for Large Monorepos
Today's Talk discusses rethinking CI in monorepos, with a focus on leveraging the implicit graph of project dependencies to optimize build times and manage complexity. The use of NX Replay and NX Agents is highlighted as a way to enhance CI efficiency by caching previous computations and distributing tasks across multiple machines. Fine-grained distribution and flakiness detection are discussed as methods to improve distribution efficiency and ensure a clean setup. Enabling distribution with NX Agents simplifies the setup process, and NX Cloud offers dynamic scaling and cost reduction. Overall, the Talk explores strategies to improve the scalability and efficiency of CI pipelines in monorepos.

Workshops on related topic

Integrating LangChain with JavaScript for Web Developers
React Summit 2024React Summit 2024
92 min
Integrating LangChain with JavaScript for Web Developers
Featured Workshop
Vivek Nayyar
Vivek Nayyar
Dive into the world of AI with our interactive workshop designed specifically for web developers. "Hands-On AI: Integrating LangChain with JavaScript for Web Developers" offers a unique opportunity to bridge the gap between AI and web development. Despite the prominence of Python in AI development, the vast potential of JavaScript remains largely untapped. This workshop aims to change that.Throughout this hands-on session, participants will learn how to leverage LangChain—a tool designed to make large language models more accessible and useful—to build dynamic AI agents directly within JavaScript environments. This approach opens up new possibilities for enhancing web applications with intelligent features, from automated customer support to content generation and beyond.We'll start with the basics of LangChain and AI models, ensuring a solid foundation even for those new to AI. From there, we'll dive into practical exercises that demonstrate how to integrate these technologies into real-world JavaScript projects. Participants will work through examples, facing and overcoming the challenges of making AI work seamlessly on the web.This workshop is more than just a learning experience; it's a chance to be at the forefront of an emerging field. By the end, attendees will not only have gained valuable skills but also created AI-enhanced features they can take back to their projects or workplaces.Whether you're a seasoned web developer curious about AI or looking to expand your skillset into new and exciting areas, "Hands-On AI: Integrating LangChain with JavaScript for Web Developers" is your gateway to the future of web development. Join us to unlock the potential of AI in your web projects, making them smarter, more interactive, and more engaging for users.
Deploying React Native Apps in the Cloud
React Summit 2023React Summit 2023
88 min
Deploying React Native Apps in the Cloud
WorkshopFree
Cecelia Martinez
Cecelia Martinez
Deploying React Native apps manually on a local machine can be complex. The differences between Android and iOS require developers to use specific tools and processes for each platform, including hardware requirements for iOS. Manual deployments also make it difficult to manage signing credentials, environment configurations, track releases, and to collaborate as a team.
Appflow is the cloud mobile DevOps platform built by Ionic. Using a service like Appflow to build React Native apps not only provides access to powerful computing resources, it can simplify the deployment process by providing a centralized environment for managing and distributing your app to multiple platforms. This can save time and resources, enable collaboration, as well as improve the overall reliability and scalability of an app.
In this workshop, you’ll deploy a React Native application for delivery to Android and iOS test devices using Appflow. You’ll also learn the steps for publishing to Google Play and Apple App Stores. No previous experience with deploying native applications is required, and you’ll come away with a deeper understanding of the mobile deployment process and best practices for how to use a cloud mobile DevOps platform to ship quickly at scale.
MERN Stack Application Deployment in Kubernetes
DevOps.js Conf 2022DevOps.js Conf 2022
152 min
MERN Stack Application Deployment in Kubernetes
Workshop
Joel Lord
Joel Lord
Deploying and managing JavaScript applications in Kubernetes can get tricky. Especially when a database also has to be part of the deployment. MongoDB Atlas has made developers' lives much easier, however, how do you take a SaaS product and integrate it with your existing Kubernetes cluster? This is where the MongoDB Atlas Operator comes into play. In this workshop, the attendees will learn about how to create a MERN (MongoDB, Express, React, Node.js) application locally, and how to deploy everything into a Kubernetes cluster with the Atlas Operator.
Automated accessibility testing with jest-axe and Lighthouse CI
TestJS Summit 2021TestJS Summit 2021
85 min
Automated accessibility testing with jest-axe and Lighthouse CI
Workshop
Bonnie Schulkin
Bonnie Schulkin
Do your automated tests include a11y checks? This workshop will cover how to get started with jest-axe to detect code-based accessibility violations, and Lighthouse CI to validate the accessibility of fully rendered pages. No amount of automated tests can replace manual accessibility testing, but these checks will make sure that your manual testers aren't doing more work than they need to.
Azure Static Web Apps (SWA) with Azure DevOps
DevOps.js Conf 2022DevOps.js Conf 2022
13 min
Azure Static Web Apps (SWA) with Azure DevOps
WorkshopFree
Juarez Barbosa Junior
Juarez Barbosa Junior
Azure Static Web Apps were launched earlier in 2021, and out of the box, they could integrate your existing repository and deploy your Static Web App from Azure DevOps. This workshop demonstrates how to publish an Azure Static Web App with Azure DevOps.