Version control is a great way to keep track of changes in your code, monitor who’s working on what, work on several features simultaneously, and generally have an overview of your projects.
There are several ways to deploy code from your Git repository to your server. Let’s go over the most common methods, each with their benefits and drawbacks.
Directly uploading to your server
A “traditional” way of deploying is to simply upload files manually using FTP or SFTP by using programs such as Filezilla or Coda. The extent to which this method is widespread can be traced, in part, to its popularity among users of technologies such as WordPress and PHP, as well as the fact that a lot of shared hosting platforms offer FTP as their default (or only) method of access to the filesystem.
Benefits: When dealing with simple (static) sites and especially if it’s a solo project, this is a quick and straightforward way of getting your files to your server.
Drawbacks: There’s numerous potential challenges to be encountered that may easily outweigh the initial (seeming) straightforward nature of this approach, namely:
- How does one make sure that all newly modified files have been uploaded to the server without having to re-upload the entire application for every new version?
- Can the application reliably be updated by hand without creating problems such as downtime?
- If the site appears broken after updating to a new version, is there an easy way to instantly roll back to a previous version?
Using version control on your server
Running Git on your server allows you to deploy changes much more easily. You’ll push changes to your repository, then log in to your server and run “git pull” to update the server with your latest changes.
Benefits: This approach solves a variety of problems that you may run into when uploading files directly to your server - as Git ensures the working copy will be fully in sync with the latest version, and uses compression to retrieve your changes when updating, reducing potential downtime. When an update causes a problem, rolling back to a previous version is relatively simple.
Drawbacks: You’ll need to have SSH access to your server and sufficient privileges to use or install git. Besides, when you want to use dependencies or a build step such as compilation or testing, you’ll run into a whole other set of problems.
Deployment scripts and Git provider solutions
To fully facilitate the deployment process, a deployment script is a great start. A deployment script allows you to capture build and deployment steps making parts of the process more deterministic, less error-prone and reusable.
We’re also seeing large git (cloud) providers moving to introduce their own CI/CD platforms, such as GitHub Actions and Bitbucket Pipelines. These are great products, but just like deployment scripts in isolation, they require a certain degree of technical know-how just to figure out the right deployment steps and server settings.
Benefits: Running deployment scripts on your own system is generally free since there are a ton open-source projects in that area.
Drawbacks: If you’re planning on running the deployment script(s) yourself, you’ll always need to have access to your system on which to execute the procedure. More importantly, the technical knowledge and time required to set up and test everything might end up being unexpectedly high. Hosted continuous integration services often include many features that are not needed for the average web-project.
Deployment automation service
Last but not least; there’s the option of a hosted build- and deployment automation service. When you’re regularly maintaining one or multiple projects, as many freelancers and web agencies do, orchestrating all those deployments can be a pain.
One of your projects may be a WordPress site hosted on an optimized WordPress hosting platform, whereas the next project could be a custom-built application based on Laravel which you’re hosting on your own VPN server that provides SSH access.
Of course it’s possible to combine several deployment technologies, such as Git, a custom deployment script, and FTP, to ensure your code eventually lands on your server.
A hosted build and deployment service such as Launchdeck allows you to seamlessly combine all those technologies with an additional layer of user friendliness, giving you the freedom to set up an ideal deployment pipeline for each of your projects.
We initially started building Launchdeck when many of the tools we tried did not adequately solve our deployment challenges. What started as a command-line based build automation tool has grown to a fully-fletched deployment automation service.
In the meantime, various new deployment services have entered the market. Despite some great advances in the available options, we still believe strongly in intelligent solutions and services that leave you with less stuff to figure out instead of more. With our one-step setup and smart automatic build configuration, you can have your next Git repository up and running in less than a minute.
You can deploy any Git repository to almost any server using FTP, SFTP and SSH. You can choose to add compilation or module bundler / installation steps, which means files that shouldn’t be tracked in version control won’t have to be, and you won’t have to install any additional software on your server either.
Find out here how Launchdeck works, and what else you can do to make your deployments even easier.