Answer the question
In order to leave comments, you need to log in
How to auto-deploy a PHP application?
Good day!
I would like to ask: how to organize an automatic deployment of a PHP application (with subsequent deployment of the database)?
The project is stored in a GIT repository (Gitlab CE).
I would like each branch to have its own subdomain and its own database, followed by migrations. Is it possible to organize this?
PS used to develop CakePHP 3, nginx web server.
Answer the question
In order to leave comments, you need to log in
You need to try Docker.
Ideology:
- a Dockerfile is being made, which describes how to deploy the project from scratch and what to do every time the container starts (for example, clear the cache and apply migrations). There are only a couple of commands you need to know - ADD (add files), RUN (run a command), CMD / ENTRYPOINT (the main container application)
- Automatic build is configured on hub.docker.com, which can kick the server via a web hook, that it's time to pick up a new one image. You can do the same with Jenkins or even your own script
- when the server is told that a new image has appeared, it downloads it, stops the current container and quickly starts a new one. Simple - a couple of seconds. If it takes a long time, you can start a new container, but not delete the old one, put nginx or another balancer in front of them and switch to a new container in it, and then delete the old one.
Ansible is used to automate the deployment of projects in any language. It's a configuration management system that's great for deployments too. www.ansible.com The web is full of example articles and code github, for example:
https://www.digitalocean.com/community/tutorials/h...
https://github.com/ansistrano/deploy
For example, Jenkins + Capistrano (or Rocketeer). Combinations - mass.
By the way, the latest versions of Gitlab should have CI support.
.gitlab-ci.yml + deployer.org (or any other deployer: capistrano, ansible, etc..)
there is also a good tool magephp.com
, unlike Deployer, it works more stably (compared with version 2 - now if I'm not mistaken there is version 3 - I haven't looked at it.)
and unlike the mentioned Rocketeer - much more thoughtful and simple architecture - write custom processes deployment under it is many times easier than under Rocketeer.
Here is an excellent article on deploying from GitLab https://coderun.ru/blog/deplojj-php-sajjta-iz-gitl...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question