I
I
Ivan Artamonov2017-03-16 17:56:21
PHP
Ivan Artamonov, 2017-03-16 17:56:21

How to properly set up a dev environment for web development?

Hi all! Guys, tell me some best practices on how to properly organize a dev environment for web development. There is the following specific case: An
international portal, with several separate services. For example, as Yandex has metrika.ya.ru, webmasters.yandex.ru, direct.yandex.ru and all these are different services/offices.
We have the same thing, we have the main portal and several separate services:

  • company.com
  • service1.company.com
  • service2.company.com
  • service3.company.com
  • admin.company.com

Let's say a company employs three programmers. There is a dev server with the following structure:
/home
  - vasya (dev1)
    - www
      - company
        - frontend
        - backend
        - service1
        - service2
        - service3
  - petya (dev2)
    - www
      - company
        - frontend
        - backend
        - service1
        - service2
        - service3
  - kolya (dev3)
    - www
      - company
        - frontend
        - backend
        - service1
        - service2
        - service3

there is a separate domain: company-dev.comand virtual hosts are configured for each developer:
dev1.company-dev.com
dev1service1.company-dev.com
dev1service2.company-dev.com
dev1service3.company-dev.com
dev1admin.company-dev.com

dev2.company-dev.com
dev2service1.company-dev.com
dev2service2.company-dev.com
dev2service3.company-dev.com
dev2admin.company-dev.com

dev3.company-dev.com
dev3service1.company-dev.com
dev3service2.company-dev.com
dev3service3.company-dev.com
dev3admin.company-dev.com

It looks like it's all wrong. Not to mention that in a company in different countries, the main domain company.com may look like company.ru, company.de, company.fr etc.
If a new developer appears in the company, then he has to create 5 subdomains and 5 virtual hosts.
If a company opens a new service, then you need to add it to each of the three (and more in the future) developers.
How to make it so that there are 5 subdomains on the prod and 5 subdomains on the dev server.
company.com 		-> company-dev.com
service1.company.com 	-> service1.company-dev.com
service2.company.com 	-> service2.company-dev.com
service3.company.com 	-> service3.company-dev.com
admin.company.com 	-> admin.company-dev.com

but each developer ended up in their own physical folder? So that it does not happen that three people work with one file and interfere with each other. In addition, so that the developer1 can tell the tester or manager, come to me and see if it works. "come to me" means to open his dev in the browser. I know that you can make your own DNS server and for each employee in the company, send him to the right folder on the server using his IP address, although everyone will have one address in the browser. But it seems that it is too difficult. Maybe there are some other options ... How do normal people do this?
There is also an opinion that each developer should deploy a local environment on his computer, but xs ...
Whoever solved such problems, share your advice, plz.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
X
xfg, 2017-03-17
@xfg

Don't think about domains. You have mixed administration and programming. No dev server needed. Do work on the local dev machine, push changes to a remote repository, and that's it. You don't have to install nginx/apache at all, etc. to the local dev machine, so as not to bother with all sorts of domains, and run the project under the built-in PHP server , for example, from the project root, and then you will access your services at localhost:port/service1/index.php, localhost:port/service2/index.phpetc.
Domains will be created already in production. In the simplest case, clone the remote project repository to the production machine and in the nginx configs you will need to write something like this

server {
  server_name company.com;
  root /home/www/company/frontend;
 ...
}
server {
  server_name admin.company.com;
  root /home/www/company/backend;
 ...
}
server {
  server_name service1.company.com;
  root /home/www/company/service1;
 ...
}
server {
  server_name service2.company.com;
  root /home/www/company/service2;
 ...
}

That's what they do. Developers don't need any dev server. They clone the repository, do something locally, and push the changes to the remote repository. For testers and all sorts of managers, they simply raise the so-called stage-server where they test the application, but this is the same as the production server, just access to it is only within the company. You can set up continuous integration so that all changes from the repository in the master branch will automatically lead to the deployment of the application to the stage and production server. This is roughly how web development works in general terms.

I
Ilya, 2017-03-16
@rpsv

Deploy GIT?
The ideal scheme in my opinion would be:
And actually the branch will not be for the developer, but for the feature / fix / dev You
can read about the structure of the repository here: https://habrahabr.ru/post/106912/
I won’t tell you how to implement this, so this is nothing more than a concept.
PS as for me, if the developers edit the same file, then it's a matter of setting tasks for them.

M
Mikhail Konyukhov, 2017-03-20
@piromanlynx

Use puppet/ansible/... and don't think about it at all

N
Nikolai Parotikov, 2017-03-23
@parotikov

I did this for myself:
There was a combat server, for example, prosto-tak.ru, and a dev server - dev.prosto-tak.ru
Started a separate domain for each developer, like
parotikov.dev.prosto-tak.ru there was access to the control panel (we used vesta cp), where he could build further a hierarchy on top of his nominal subdomain: project1.parotikov.dev.prosto-tak.ru, project2.parotikov.dev.prosto-tak.ru
Further, if necessary even more detailed, you can add the release version, branch name, etc: feature.project1.parotikov.dev.prosto-tak.ru, service.project1.parotikov.dev.prosto-tak.ru
Yes, it looks a bit redundant, but worth it once to explain to everyone this domain model, namespace, so to speak, and everything becomes very harmonious.
The burden of creating your own subdomains fell on the developer himself, since everything is done there in 3 clicks. Who needs it - he creates the necessary structure for himself, and nothing superfluous is duplicated for him.
In a conversation, it’s generally very simple: Pupkin tells you - open a site with a branch55 branch on the third service. And you open branch55.service3.project1.pupkin.dev.prosto-tak.ru. And locally at home, so as not to drive in a long url every time, you can also hang an alias in hosts.
PS: But if it's massive, then it's better to use some kind of ansible conductor with templates.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question