1

I have 2 rails applications that live inside the same git repo.

There is a shared folder where common logic lives.

- app_1

- shared

- app_2

The shared folder is really just a symlink to the appropriate places inside the app_1 folder. There is also a shared_public folder that is symlinked to app_1/public/files and app_2/public/files.

How can I do this? I'm open to anything, it's a clean slate. The project was never deployed previously, so I don't have a existing infrastructure to rely on. And splitting the shared logic out is (unfortunately) not an option currently, because of the timeframe I have to work with.

1 Answers1

0

Git

When you mention the shared folder is a symlink - this only exists in operating systems, not git

Since git is just a deployment mechanism in this instance (I.E will place your files from your repo onto your server), you'll probably be able to do the following:

  • Initialize a git repo on your server ($ git init on your server)
  • Clone your github repo locally (git clone https://github.com.... on your local box)
  • CD into your new folder and add the server's repo as a remote
  • $ git push [server repo name] master

This isn't what you want, I know.

It will push your files onto your server - so you'll get the following folder structure:

  • app1
  • app2

The shared folder could then be created on your server itself.

If you have your appropriate server setup, you should be able to get this running from performing these steps


Capistrano

If you want to use Capistrano, you'll have to do something a little more involved, as this does more than just push your files to your server

If you want to use Capistrano, you'll have to split your app1 and app2 into separate applications, and deploy them individually. This will still allow you to create a symlink on your server, except you'll have a slightly different structure to your directories

Richard Peck
  • 76,116
  • 9
  • 93
  • 147
  • [Git understands symlinks](http://stackoverflow.com/a/954575/3785131). It stores the relative path in the directory. And the capistrano section is no help, what do you mean by "into separate applications"? Do I need to split them out into different git repos? – user3785131 Jun 28 '14 at 13:14
  • My apologies - seems like I was wrong! I would personally split into different git repos sorry – Richard Peck Jun 28 '14 at 13:23
  • So how would I do this? Would I have `app1`, `app2`, and `shared`, and then keep them all in sync via submodules, or should I use [subtrees](http://blogs.atlassian.com/2013/05/alternatives-to-git-submodule-git-subtree/)? – user3785131 Jun 28 '14 at 13:35
  • That's what I considered at the beginning. However, I wasn't able to convince myself that was sustainable. – user3785131 Jun 28 '14 at 13:36
  • Well it depends on what you're trying to do. When you say you have "shared functionality" - what do you have? EG couldn't you create a `gem`? – Richard Peck Jun 28 '14 at 13:38
  • Database models (this gives me nightmares), some business logic and a few homegrown libraries. I'm working on splitting the homegrown libs out, but still leaves me with the business logic and models. – user3785131 Jun 28 '14 at 13:56
  • Hmm okay - got any case examples? – Richard Peck Jun 28 '14 at 14:14
  • The contents of `app1/app/models` is shared with app - app2 has *no* models that app1 doesn't have. – user3785131 Jun 28 '14 at 17:07