Hello, there is a restful service written in golang. I used to work on a local host, but now there is a need to deploy everything to the server. I can not understand how best to implement deploy. I created a repository on the bake, and from then on I'm stupid. Each change (And there will be a lot of them) to copy, build, then close the process with the active go application and launch a new one. Since the changes will be very frequent and very interested in how you can automate this process.
2 answers
There is an approach called Continuous Delivery that offers a solution to the problem you describe.
What the beast is and what it is eaten with is described in the book Continuous Delivery: Reliable Software Releases through Build, Test, and Deployment Automation . Automation of build, testing and implementation of new software versions
Minor CD squeeze (quote from here ):
The basic idea of ​​the CD is to build a Deployment Pipeline, allowing each change in the version control system to get into the combat environment in a standard and fully automated way.
It might look something like this:
- Changes are made to the version control system (SCR).
- The system of continuous integration is started (Continuous Integration, CI), the build is assembled (if it is a compiled language), all the necessary tests are run.
- If the previous step is successful, the build rolls out to the testing environment (QA).
- After successful testing, the build rolls out to the stage environment (pre-production), which is as close as possible to the combat environment.
- If everything went well, then the build gets into the combat environment.
Here the question arises in full growth, how to make so that all environments, starting with the developers, are the most consistent with each other. To do this, there are configuration management tools (Configuration management system). The most important thing is that the configuration of the environments is the same code, and all of the above approaches are also applicable to it: storage in hard currency, CI, testing.
So, if this process is debugged, all changes pass through it, and, potentially, every change can be rolled into production, this is called the process of continuous software delivery.
- hehe, you are 2 minutes ahead ... - Lex Hobbit
In any case, you need solutions for CI (Continuous Integration) and CD (Continuous Deployment) .
Here is a list from which you can choose ( link ).
For example, how it works with Drone :
- Through the Drone web muzzle, you set up Drone to get the project from the Git repository and perform a “launch”. What exactly happens at startup is described in the next step.
- Together with the application code in the repository there should be a
.drone.ymlfile that tells Drone how to install and run your application. - Next, you do a
git pushto your repository, Drone checks the repository for the newly uploaded Docker image (of your choice), and then starts it. - Based on your configuration, the result of a successful launch may be a notification (“Build completed successfully!”), The creation of a binary version, or even a deployment.
- Finally, Drone removes the Docker container and reinstalls it so that it is in its original and known state for the next build.
PS for a bunch of Drone + Docker there is a good article on Habré .
