0

I have a web project in. Say, it's in Rails, or any other well web framework. And I plan to be creating copies of it and running them all. Let's say, it's a blog. Each blog will be deployed on its own domain and they basically, 90%, will be identical. And around 10% will be unique, custom on each blog.

Whenever I update the code of 'Blog1' locally, I'll push an update to git, then I'll log in to the servers of other blogs and do "git pull" to retrieve an update, and rebuild them. An update won't overwrite the 10% of custom stuff of each blog.

Custom stuff will include: js, css, images files, some parts of the pages, names, texts, etc...

(1) How will I organise all that? The amount of js, css, images, etc can very on each blog, therefore I can't simply add "custom_style.css" to .gitignore

Saving css, js, image in a database isn't an option, because retrieving them on each request will cost too much.

Or perhaps, do it somehow statically and only once at booting a blog, when they'll be retrieved from Sqlite3.

(2) And how would I go about rendering unique parts of html pages? Such as footers, top nav bars. They may or may not, or may be partially different.

(3) All the code itself will identical, at this point, probably. Otherwise, how would I go about code as well? Namely, some blogs would have peaces or whole files of code unique to them. Something similar to plug-in system, I figure.

P.S. I'm aware of tenant architecture, that's not completely it.

Keeping sub-config.yaml file of each project in .gitignore is given.

There'll be only a single main branch here.

1 Answers1

1

Ok, let us assume you are not trying to abuse branches in your web application. Instead, you have isolated the customizable parts in your system in separate files, and the only question you need to answer here is how to manage the deployment process.

You wrote

Whenever I update the code of 'Blog1' locally, I'll push an update to git, then I'll log in to the servers of other blogs and do "git pull" to retrieve an update

and that is probably the point where you should change something. Customized deployment simply needs a more sophisticated deployment process.

First, make a subfolder in your web system for each customer with all the customer specific files. I am not a Git expert, but things may be easier if that subfolder is not placed under the root folder of your main system, but somewhere else.

The process should then

  • pull the latest version of the web sources from the repo (maybe it is the latest one, maybe not, you should be able to control this), without the customer specific ones (maybe you have some standard template files for those)

  • pull the sources for the specific customer from the corresponding subfolder

  • replace the "standard template files" by the customer specific ones by copying from the customer's subfolder into the right place.

For this, the most simple solution could be to create a script in your favorite shell scripting language which implements exactly the steps described above. A more advanced solution may utilize specific web deployment tools (google for "web deployment tool" to find several free or commercial ones).

Doc Brown
  • 218,378