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!

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
Learn more about how to leverage the default features of npm workspaces to help you manage your monorepo project while also checking out some of the new npm cli 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
This talk introduces the new Flat Routes convention that will most likely be the default in a future version of Remix. It simplifies the existing convention as well as gives you new capabilities.
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
Code tasks like linting and testing are critical pieces of a developer’s workflow that help keep us sane like preventing syntax or style issues and hardening our core business logic. We’ll talk about how we can use GitHub Actions to automate these tasks and help keep our projects running smoothly.
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
Demand for DevOps has increased in recent years as more organizations adopt cloud native technologies. Complexity has also increased and a "zero to hero" mentality leaves many people chasing perfection and FOMO. This session focusses instead on why maybe we shouldn't adopt a technology practice and how sometimes teams can achieve the same results prioritizing people over ops automation & controls. Let's look at amounts of and fine-tuning everything as code, pull requests, DevSecOps, Monitoring and more to prioritize developer well-being over optimization perfection. It can be a valid decision to deploy less and sleep better. And finally we'll examine how manual practice and discipline can be the key to superb products and experiences.
Why is CI so Damn Slow?
DevOps.js Conf 2022DevOps.js Conf 2022
27 min
Why is CI so Damn Slow?
We've all asked ourselves this while waiting an eternity for our CI job to finish. Slow CI not only wrecks developer productivity breaking our focus, it costs money in cloud computing fees, and wastes enormous amounts of electricity. Let’s take a dive into why this is the case and how we can solve it with better, faster tools.
The Zen of Yarn
DevOps.js Conf 2022DevOps.js Conf 2022
31 min
The Zen of Yarn
In the past years Yarn took a spot as one of the most common tools used to develop JavaScript projects, in no small part thanks to an opinionated set of guiding principles. But what are they? How do they apply to Yarn in practice? And just as important: how do they benefit you and your projects?
In this talk we won't dive into benchmarks or feature sets: instead, you'll learn how we approach Yarn’s development, how we explore new paths, how we keep our codebase healthy, and generally why we think Yarn will remain firmly set in our ecosystem for the years to come.

Workshops on related topic

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.
How to develop, build, and deploy Node.js microservices with Pulumi and Azure DevOps
DevOps.js Conf 2022DevOps.js Conf 2022
163 min
How to develop, build, and deploy Node.js microservices with Pulumi and Azure DevOps
Workshop
Alex Korzhikov
Andrew Reddikh
2 authors
The workshop gives a practical perspective of key principles needed to develop, build, and maintain a set of microservices in the Node.js stack. It covers specifics of creating isolated TypeScript services using the monorepo approach with lerna and yarn workspaces. The workshop includes an overview and a live exercise to create cloud environment with Pulumi framework and Azure services. The sessions fits the best developers who want to learn and practice build and deploy techniques using Azure stack and Pulumi for Node.js.