After a long and difficult month when I realized
just because Heroku uses the git repository as a deployment mechanism, you should not consider it as a git repository
it could be rsync as well, they went for git, don't get distracted because of this
if you do, you will discover all kinds of grievances. All of the above solutions are somewhere depressing:
- this requires that something is done every time or periodically, or unexpected things happen (pushing submodules, synchronizing subtrees, ...)
- If you use the engine, for example, to modulate your code, the Bundler will eat you alive, it is impossible to describe the amount of disappointment I had with this project during the quest to find a good solution for this
- you are trying to add the engine as git repo link +
bundle deploy - crash, you need to bind update every time - you are trying to add an engine like
:path + bundle deploy - fail, the development team considers :path option like "you are not using the Bundler with this gem option", so it will not be linked for production - also, every engine update wants to update your rails stack -_-
- The only solution I found was to use the engine as a symbolic link
/vendor in development and actually copy the files for production
Decision
In this application, there are 4 projects in git root:
- api - depending on the profile, it will work on two different heroku servers - upload and api
- Web site
- web old - an old website still in the process of migration
- common - common components extracted in the engine
All projects have a vendor/common symbolic link looking at the root of the common engine. When compiling the source code for deployment in heroku, we need to remove its symlink and rsync code to physically reside in the vendor folder of each individual host.
- takes a list of host names as arguments
- launches git push in your development repository, and then launches a clean git pull in a separate folder, making sure that no dirty (unmanaged) changes are automatically transferred to the hosts
- deploys hosts in parallel - relaying each heroku git, new rsynced code to the right places, with the push database in the git commit comment,
- in the end, we send ping with curls to tell the owners a hobby to wake up and start magazines to see if all the fault.
- plays well with jenkins: D (automatic code entry for testing servers after successful tests)
Works very well in the wild with minimal (no?) Problems after 6 months
Here's the script https://gist.github.com/bbozo/fafa2bbbf8c7b12d923f
Update 1
@AdamBuczynski, it is never that simple.
1 you will always have a production and test environment, at least, and a bunch of functional clusters in the worst case - suddenly one folder should display n heroku projects as a fairly elementary requirement, and all this should be organized so that the script “knows”, which source do you want to deploy where
2nd you want to share the code between projects - now comes the sync_common part, shennanigans with symbolic links in development, replaced by the actual rsynced code on Heroku, because Heroku requires a specific folder structure, and bundler and rubygems really do things ugly very badly if you want extract common flows into a gem
3rd you will want to connect CI, and it will change a little, how to organize subfolders and git repos, in the end, in the simplest case of use, you will get the above meaning.
In other projects, I need to connect Java assemblies, when you sell software to several clients, you will need to filter the modules that are installed depending on the installation requirements and something else,
I really should consider combining things in a Rakefile or something else and do it like this ...