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
    Does this answer your question? [Maintain hundreds of customized branches over master branch](https://softwareengineering.stackexchange.com/questions/302147/maintain-hundreds-of-customized-branches-over-master-branch) – Doc Brown Aug 14 '20 at 06:42
  • See also: [How to manage source code customizations for many users?](https://softwareengineering.stackexchange.com/questions/97353/how-to-manage-source-code-customizations-for-many-users) – Doc Brown Aug 14 '20 at 06:43
  • @DocBrown not precisely. Besides, there're pieces of advice there, but I've asked concreate questions – zirnamaraji Aug 14 '20 at 08:37
  • 3
    The general strategy should be clear from those former questions: don't abuse Git for this purpose, make customization a feature of your software. The gory details of how to make CSS, HTML, or "code" customizable are hard work. Each one probably worth one or more questions on **Stackoverflow** - ideally after you tried something out, and you run into real issues, not just at the whiteboard. – Doc Brown Aug 14 '20 at 09:04
  • @DocBrown this forum is for asking specific questions. I've asked them. – zirnamaraji Aug 14 '20 at 12:09
  • Your questions would be more specific if you tried out something real and could tell us why it did not suit your needs. And it is usually not a good idea to ask three questions in one on this site, since it makes a question prone to become closed by the standard "needs more focus" reason. But give me a minute, I think I can write an answer anyway. – Doc Brown Aug 14 '20 at 13:34
  • Storing the assets in the database doesn't mean you need to retrieve them on every request any more than if they were stored in the file system. You use etags to determine if they need to be retrieved again, or if the copy the client has in its cache is still valid. This technique makes sense if you expect someone to change these in a web interface for administrators. – Salvatore Shiggerino May 14 '21 at 10:20

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
  • 199,015
  • 33
  • 367
  • 565