How do you setup your Vagrant projects in Git?

So, I decided to put my project over on my home server to free up memory on my main machine and I’ve decided to go with Vagrant.

I have everything setup and working and it was really nice. But how do you have it setup in your Git repos? Is there a preferred way of doing this?

Do you just have the main /vagrant/ folder as your top level folder in your project and move your code into a /src/ folder or do you do it some other way? Doing it that way seems less pure to me.

Yup, that way. And I’m pretty sure that’s the standard kind of setup, too. A project’s root will have files such as your vagrantfile, your composer file, your phpunit file, a build or make file, so on and so forth. And then, yes, all your code is kept in a /src folder.

1 Like

Cool thanks. It just seems odd to me to do it this way, but I guess it doesn’t matter.

So I’m still a bit new to vagrant, but are you simply defining your structure inside your vagrant VM? or outside of it in your repo?

As most of the projects I’ve worked on, simply have a VagrantFile in their repo and nothing else. It just sits at the root level of the project…

Yeah, I added it to an existing project and was wondering how most people set it up. I’ll move my code down in the repo and the vagrant to the top.

projectfolder
|-- Vagrantfile
|-- bootstrap.sh
|-- .gitignore
|-- src
    |-- Actual Project

I actually think that structure is pretty good. Here is one of the projects I was referring to

You can quickly see having everything in the root directory is a bit “overwhelming”. I like the idea of having your project related files in its own folder (src) and anything that is helpful to getting the project running above that directory.

1 Like

lol. Doing it like that never really crossed my mind, actually.

That might be more confusing to look at, but it might work out better inside IntelliJ. I was considering Subprojects and Submodules and all sorts of stuff. I over-think problems too much.

Yeah, it does work pretty well in IntelliJ, That is what I use to work on that project. Granted, the VM in the vagrant file was a bit quirky so I eventually just created my own environment, but nonetheless, it functions :smile: (still can’t help to wonder if there is a better way though, especially for a project that size)

1 Like

the VM in the vagrant file was a bit quirky so I eventually just created my own environmen

Here’s mine if you’re interested.

It’s very basic, I just used a shell script to set it up instead of doing all that fancy chef/puppet stuff I didn’t really need. I used someone else’s example which I should probably fork I guess… idk I don’t really use github.

I installed a localhost Discourse as per


i.e. installed
VirtualBox
Vagrant
Git

then using the Git UI to start up the localhost server.

Interacting with GitHub via the UI is easy enough for what I need to do, but …
Discourse requires symlinks (for full functionality) and that requires running Power Shell as Administrator. Something I have been unable to do via the Git UI on my Windows 7 Home OS (tool is available for Pro, online Registry hack examples I don’t want to try)
I can run the server from Power Shell as Administrator, but by not using Git I now need to figure out the SSH stuff.

@mawburn is your github something that might help me over this stumbling block?

Hard to say, as his really would just show you how he setup his Vagrant file.

I can zip up the virtual machine I use for Discourse. I even have a few “helper” items in there for quickly updating Discourse with latest and it uses generic logins so, there isn’t anything “secretive” that I’d be worried about sharing.

is your github something that might help me over this stumbling block?

Doubtful. That was just me playing around seeing if I could get it to work. Which I did, now I decided to go another route. :smiley: (I do the Play locally and host the PostgreSQL on my homeserver) It didn’t really work out the way I’d hoped and was more pain in the butt getting the code to sync properly.

but by not using Git I now need to figure out the SSH stuff.

PuTTY is a good windows terminal for SSH. WinSCP is a good SFTP client. I don’t know how to use Powershell like in their guide.

tbh, I actually don’t even use the vagrant ssh command and just ssh directly into the VM.