📜 ⬆️ ⬇️

How to organize working copies of multiple projects for multiple developers on a single development server

Why work at all on the development server, because each developer can raise his working copy on his local machine?
Firstly, this is probably not always the case - there are cases when this or that software necessary for the project to work refuses to work or simply does not exist for the OS used on the developer’s machine, secondly, the version and settings of the installed software will have to be controlled and the team will be constantly encounter problems like “And it works on my machine,” at the same time, developers will have to independently install all the software necessary for a project on their machine; thirdly, the project’s work is often significantly tied to the database nnyh and developers will have to carry a dump database each time a significant change for the project will be made in her fourth - it will be difficult to show the client operating time of a working copy.

It is easier to work on the same development server, since all the necessary software is already installed and configured on this server and one copy of the project database is raised.

Given

There are two developers, ivan and vasja, who are working on two web projects, project1 and project2.
It is necessary to organize 4 working copies within the development server, which will be accessible from the browser at the following addresses:
  http: //project1.ivan.devdomain/
 http: //project2.ivan.devdomain/
 http: //project1.vasja.devdomain/
 http: //project2.vasja.devdomain/ 
where devdomain is a real domain, for example mycompanydev.ru
Of course, each of these domains will contain a separate working copy of the project, which will allow developers to work independently from each other while remaining on the same development server and working with the same database.
')

Implementation on linux server using nginx

I will only consider nginx, because I just don’t know how to do the same on another web server, perhaps in the comments someone will tell me how to do the same for Apache.
What do we need:
  1. The real domain is for simplicity and in order that the developments can be shown to the client from any working copy. Suppose in our case it is mycompanydev.ru, in the DNS of this domain you need to give the entire * .mycompanydev.ru zone to the IP of our development server.
  2. Home directories for each developer on the development server, let's say they are in / home /, like this: / home / vasja /, / home / kolja /, / home / ivan / and so on. Of course, the developers of these directories should be mounted as network drives.
  3. Working copies of the projects are in the home directories of the developers - /home/ivan/project1.mycompanydev.ru/ or /home/vasja/project2.mycompanydev.ru/
  4. It remains to configure nginx
      server {
             listen your.server.ip.addr: 80;
    
             server_name .mycompanydev.ru;
    
             if ($ host ~ "^ ([^ \.] +) \. ([^ \.] +) \. mycompanydev \ .ru $") {
                 set $ lroot /home/$2/$1.mycompanydev.ru;
             }
    
             root $ lroot;
    
             # further $ lroot can be used for example for fastcgi_param SCRIPT_FILENAME
     } 

Now a new project can be added by simply creating a folder in the working directory of the developer, for example, like this /home/vasja/superproject.mycompanydev.ru and will immediately be accessible from the browser at http://superproject.vasja.mycompaydev.ru/ without having to something to customize.

Important: it is assumed that the development server is located in the office and is accessible on the local network

I hope this material will be useful to someone, since we once puzzled for a long time before we came to this decision.

Well, as usual - questions, advice, criticism - everything is welcome.

Source: https://habr.com/ru/post/40576/


All Articles