3

I'm planning a project that consists of the following parts:

  1. REST API in Lumen
  2. Web client in Laravel
  3. Product website in Jekyll

These separate products are going to be running on the same server.

I'd like to have a development environment that mimics the production environment as closely as possible, that's why I'm going with Vagrant in combination with a single Ansible playbook that provisions both environments.

What's the best way to organise such a project? Should I keep everything in one repository, or should I split up the parts into multiple repositories?

What about the development environment and provisioning scripts? Should I put these in a separate repository? How would I go about referencing the separate parts of the project in the development environment?

I'd like to be able to clone a single repository and spin up a development environment with as little work as possible.

Any recommendations?

Edit: My question differs from this question because I'm especially struggling with things related to production and development environments.

amon
  • 135,795

2 Answers2

3

After some fiddling around, I came up with a solution that seems to work pretty well.

I keep the subprojects in separate repositories:

  • projectname-infrastructure
  • projectname-api
  • projectname-client
  • projectname-website

The project-infrastructure-repository contains a Vagrantfile, some provisioning files and an Ansible playbook that is run locally in order to set up the development environment:

--- - hosts: 127.0.0.1 connection: local tasks: - git: repo=https://name@example.com/projectname-api.git dest=www/api/ - git: repo=https://name@example.com/projectname-client.git dest=www/client/ - git: git: repo=https://name@example.com/projectname-website.git dest=www/website/

When the above playbook is run, the separate repositories are cloned into the www-folder that nginx on Vagrant uses to serve files.

Of course, the www-folder is inside of the .gitignore of projectname-infrastructure.

The only thing I need to do is git clone https://name@example.com/projectname-infrastucture.git, followed by ansible-playbook setup.yml -i 127.0.0.1,. Then I can just execute vagrant up and everything is up and running.

Any downsides to this approach?

2

I'd suggest using same repo even if parts are running on different servers. And I wouldn't split setup scripts (e.g. ansible playbook) into different repository too, because it is the same project any way.

It is just a matter of convenience: you only need one checkout to get started as a developer, tester or support engineer. And I wouldn't bother about provisioning unneeded parts of a system to a server, because ansible could take care of that.

name_no
  • 139