How a lone developer correctly build the process of creating and deploying software – experts answer

These days, I can’t imagine writing code without Git. Even if I’m working alone on a pet project.

First, I always know which files I edited and what exactly I changed in them. This allows you to edit the code without fear, and it is much easier to find the reasons for the inoperability of the code. Any changes can be seen after a long break in the project and even after restarting the computer. Which is not possible when using ctrl + z.

Secondly, if in the process of work the whole project was broken or for some reason it was not possible to implement the functionality or I realized that it was all a bad idea, I can return the previous version of the project with one command. Or even experimenting on the test branch, and making features on the stable branch.

Also, without a version control system, it is impossible to implement a site or application deployment. Only if you write a script that will completely upload all files to the server via FTP or SSH. But such a process will be long and difficult – at any time, the connection may end and you will have to do everything again. And with Git, you can at least connect to the server and do git pull… Once upon a time, we even used this approach in production.

However, this was before web applications needed to install dependencies and build. But even now it is quite easy to write a script, for example in bash, which will clone a new version of the project into a separate folder, do npm install, npm run build and change the symbolic link. And in case of problems, run the script to switch the symbolic link to the folder with the previous version. Deploy on your knee is ready.

In order to avoid problems with self-written solutions, I can advise you to use the Ansistrano utility. It does everything that is described above and at the same time it is not necessary to log into the server. You can run the script directly from your machine. Deployment and rollback scenarios are described in declarative yml files. Plus, all actions are idempotent and there are flexible settings: branch, tag, commit from which to deploy, the number of backups saved, and so on.

For me, this is the minimum comfortable level of work on projects. Automatic deployment saves you from routine actions and saves you from mistakes caused by the human factor.

Going a little further, you can master the basic functionality of Bitbucket Pipelines or GitHub Actions. Their scripts are also written in yml files, only the syntax is different everywhere. But on the plus side, you get prepared scripts, which, for example, can use npm caches, which significantly speed up the process, and many other features. You can also organize automatic deploy by merge to master or by adding a tag. And these will already be real CI / CDs.

The most important thing is that having spent a small amount of time and effort once on mastering these technologies, you get cool and convenient tools that make life easier every day and save time.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *