Git project with two separate folders

Asked

Viewed 25 times

1

Hello,

today I have a web project. The public data inside the folder "public_html/":

public_html/projeto-publico/

and another folder with sensitive files ("project-backend") is outside "public_html/":

projeto-backend/public_html/...

Basically a folder has the . php files and the folder publishes the . js and .css. Both are from the same project. Would you like to know how, do I organize this in git? Since they are different folders. I would have to have 2 separate repositories for each folder in git?

Thank you!

  • hello Thiago, as far as I know the permissions are by repository, so if you want to have different access to each one you will need to have different repositories

  • That’s what I thought too, but since I’m new to git I thought he might have an alternative to that.

1 answer

0

Okay, I believe that there are several possible answers to this question, I’m going to raise two possibilities and approaches.

Separate Repositories

One option would be to have two applications, one front-end and one back-end, in this scenario the ideal would be to have a well decoupled front from the backend, where communication occurs through http or sockets.

In this scenario you would have:

  • A replacement for the web frontend application (HTML, CSS, JS (May or May not use something like angular, React, etc)).
  • One or more backend applications

Communication occurs through one or more backend Apis consumed by the front end.

Monolith

Observing your question is quite possible that you already have a monolith, in this case it is not necessary to break it into multiple repositories.

It is possible to hold this monolith together and still make the deployment of the desired shape.

In some frameworks like Laravel in PHP, Rails in Ruby there are directories for the static files and the front controller that processes the requests.

In these cases it is possible to deploy your application outside the directory of your web server (apache, Nginx, etc.) and add a symbolic link on your web server.

UNIX and Windows operating systems have this feature, where you can create a "shortcut" to a folder within another folder, where for all purposes this shortcut is handled by the applications (e.g. Web Server) as being the folder, in this case assuming that you had an apache server on linux you could do something like this:

  • /var/www/aplicacao/ - Deployment directory of your application.
  • /var/www/aplicacao/public/ - Directory with Assets and front controller
  • /var/www/public_html/ - Apache Web Directory
  • /var/www/public_html/aplicacao/ - Symbolic link to /var/www/application/public/

Changing apache settings to serve the directory /var/www/public_html/aplicacao/ on a given domain and adjusting access settings you wouldn’t have to worry about someone being able to access files outside the directory /var/www/aplicacao/public/ when accessing your domain.

  • Then the two folders would be in the same repository ? And how would it look when deploying on the server so that each folder goes to its proper place?

  • Hello Thiago, in this case you would not separate the folders. Instead of separating you do Depot where the server cannot serve them. Then you create inside the server folder a symbolic link to the public folder (with the index.php and the Assets) so that this is only this folder can be served.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.