Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the 'standard' directory location to use when cloning a Git repo onto a LINUX machine

While I spend most of my career on the Microsoft stack as a full-stack web developer - I have, on occasion, made my way into the *NIX side of things.. built out a FreeBSD web server here, played with Caldera Linux once over there, and am currently doing some web deployment using a Google cloud VM that is running Ubuntu...

TL,DR So, if I forked a repo onto my GitHub account- all for the purposes of then cloning it into my Ubuntu server where I'll then compile and run the web application..

What is the professionally expected location that I should put that 'cloned' source code? I googled around a bit to get a better grasp of what the various linux directories are for.. but.. I need a good SO answer... so... where would you put it?

/usr/src/MyGitRepos ..that sounded good to me.. but.. what would you do?

like image 959
bkwdesign Avatar asked Jan 21 '16 03:01

bkwdesign


2 Answers

What is the professionally expected location

If as you say you're deploying an app that's compiled from source, then there's no such location. In a professional environment your sources don't go on the servers.

From most professional to "it works" solutions:

  1. Build system packages outside of your production environment. That means you have a repository of both previously deployed versions and have a package manifest including both build and runtime dependencies. That means you can rebuild your app the same way every time. For installation, install the built package. (this applies to deb, rpm, etc.)

  2. Build tarballs with binaries in a predictable environment (developer's box). That means you run (for example, if you're using autotools) ./configure --prefix=/opt/your_app && make install DESTDIR=/tmp/somedirectory - now you can pack the /tmp/somedirectory/opt/your_app contents, copy it to a server and unpack it to /opt/your_app.

  3. Clone it wherever (your home directory), then build, then install in the destination. Popular destinations are /opt/app_name and /usr/local.

The solution depends on how professional the deployment really is, how many servers you've got, have you got test/production environment, etc.

like image 75
viraptor Avatar answered Sep 28 '22 00:09

viraptor


I wouldn't say there is a standard assumed place, especially if the server is specifically for this application. Putting a folder for it in the /home/user directory should be fine even, or organising it any way you see fit from that point:

/home/user/app-goes-here/app.js

Just keep it simple :)

like image 28
2 revs, 2 users 99% Avatar answered Sep 28 '22 01:09

2 revs, 2 users 99%