A long time ago we had a question: how easy and fast is the deployment of a front-end project?
We thought about a tool like Jenkins. Many who set it up know: setting up takes a lot of time and, more importantly, a lot of system resources are spent. Raising it on the server means allocating one and a half gigabytes of memory. Such a pleasure, when you have 500 megabytes for everything, for example.
An alternative is Mina. This is a great solution, and we use it in Ruby projects. But what if you only have a front-end? Put Ruby and Bundle? No, it is too difficult. Mina, of course, has great functionality, but we want to do it on NodeJS without any extra gestures.
As a result, we wrote Bash scripts, but it tired us out. And we had the idea to write a small service for deploying front-end applications, which would be:
- npm package
- have a small and simple config
- take 10 minutes to set it up and 5 minutes to deploy
- have a release system (if something goes wrong anyway and someone says, “it’s
broke ", then you can safely and quickly return to the previous release)
And we made
Runy - a convenient and practical tool for deploying front-end.
All you need to configure it and the first deployment after installing the package are three commands:
init - create a config and enter your data into it
setup - create project structure
deploy - secure your project
And it's all!
This module has simplified our lives! Now the deployment is a team. Quick and easy. When new developers come to us, you can give them access to the dev / stage server so that the guys can deploy themselves. Junior developers will also be useful, for use does not need a threshold of entry, and in the future they can understand the module and acquire new knowledge.
It is a little about technical part (more detailed manual is on
github ). At the moment, Runy has the following commands: init, setup, deploy, unlock, rollback.
Init
Creates a config file in the place where the command is called. You should enter your data into it. As you can see, we use the connection via ssh-agent, so no passwords will be in the config.
// runy.js module.exports = { host: '0.0.0.0', // username: 'username', // port: 22, // remotePath: '/your/project/path', // git: 'link-to-your-git-repository', // ( ssh) agent: process.env.SSH_AUTH_SOCK, // commands: [ // 'npm install', 'npm run build', ], };
Setup
At the specified path in the config, it creates the releases folder (it stores releases by numbers 1, 2, 3, etc.) and the .current.release file (it stores the current release number).
Deploy
This team has some protection, at the same time only one person can produce warmth.
The team does the following. Creates a temporary folder, installs a project, executes a list of your commands from the file config (commands) for pulling dependencies and building the application, creates a new release folder, transfers the newly assembled project there, checks the number of releases and deletes the old ones (3 releases are now stored), creates a symbolic link to the current release (the current release will always be available via the given path your-remote-path / current), updates the file with the release number, cleans the folders.
Unlock
Removes the security file that is created when the deploy command is executed. In general, the file is deleted automatically and even during error handling, but this command exists for all cases of life.
Rollback
It returns a symbolic link to the previous release and deletes the current one.
PS We still have ideas for the development of this tool, you can also participate in the development of the project by creating / doing tasks
here .
Let the deployment of each developer will be more convenient and faster.