Separate FE and BE on Heroku but single repo on Github?

0

Issue

Setup

I have a web project whose front and backends are hosted on Heroku separately. It is stored in my machine as so:

project root
├── backend
│   ├──── stuff
│   └──── .git
├── frontend
│   ├──── stuff
│   └──── .git
├── project-wide config files
├── scripts
└── README.md

Problem

As you know, deployment to Heroku requires the backend and frontend folders to have their own git folders… but on Github, I want to unify this whole project into one repo, like it is on my machine.

What are the best practices to this issue? Is git submodules a good solution?

I am also entertaining the idea of docker-composing this whole project.

Solution

The usual approach is to define a third Git repository, one which will reference the other two (front and back).

That reference would be registered as submodule, allowing any one cloning the parent repository to get the latest of said sub-repositories:

git clone --recurse-submodules --remote-submodules 

Don’t forget, when you add those submodule, to specify a branch in order for the parent repository to get the latest of those submodules.

Using GitHub CLI gh:

git init myProject
cd myProject
git submodule add -b main [/url/repo/front]
git submodule add -b main [/url/repo/back]
git commit -m "Add front and back repositories"
gh repo create myProject --source=.
git push -u origin main

Answered By – VonC

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave A Reply

Your email address will not be published.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More