Search code examples
linuxubuntugoogle-cloud-platformcloudgoogle-compute-engine

Best practice to store code on Google Cloud VM instance?


I have a GCP compute engine VM instance. Under /home folder there are multiple users and they all have their respective SSH keys:

(base) user1@a100-80gb:/home$ ls
user1  user2  user3  user4  user5

I want to create a /code folder for managing multiple codebases and everyone can access it. What is the best practice for such a task?

Is creating a /code folder under /home the best way? But if I do so /code folder does not have its own ssh key that I can add to GitHub(Or I can just ssh-gen one under the /code folder?) Something like:

(base) user1@a100-80gb:/home$ ls
user1  user2  user3  user4  user5 code

For reference, here're the folders under /:

(base) user1@a100-80gb:/$ ls
bin   dev  home  lib32  libx32      media  opt   root  sbin  sys  usr
boot  etc  lib   lib64  lost+found  mnt    proc  run   srv   tmp  var

Solution

  • As @John Hanley mentioned, storing code on VMs is not recommended. Source code repositories are a better alternative to storing code on VMs. Cloud Source Repositories also provide a source viewer and a complete Git solution with the Cloud Shell.

    Google Cloud Source Repositories provide Git version control to support collaborative development of any application or service, including those that run on Google App Engine and Google Compute Engine. Cloud Source Repositories also provide a source viewer that you can use to browse repository files. Combining this with the Cloud Shell, with its built-in editors, gives you a complete Git solution from within the console.

    With Cloud Source Repositories, you can have any number of private Git repositories, allowing you to organize the code associated with your cloud project in whatever way works best for you.

    Refer to this link on How to create code repositories in Cloud Source repositories.