1

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 – Doc Brown Aug 14 at 6:42
  • @DocBrown not precisely. Besides, there're pieces of advice there, but I've asked concreate questions – zirnamaraji Aug 14 at 8:37
  • 2
    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 at 9:04
  • @DocBrown this forum is for asking specific questions. I've asked them. – zirnamaraji Aug 14 at 12:09
0

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).

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.