7

How do I deploy a Rails app with Capistrano to a production or staging server which has no access to an external network or repository ?

I've managed to get half way through the deployment and realised that Capistrano doesn't download the git repo on my local machine, but it first connects to the remote server and it tries to download the Git repo there.

I would have expected a Java-ee-like build system in which a deliverable is created and that deliverable is sent to the server. Just like you would build the .ear file and deploy it on whatever server you want to. Apparently in RoR you are forced (as far as I can see) to build the app on that server, create a gem repository there, clone the latest branch there and so on.

Is there any way to send an ready-to-run package to the remote server?

halfer
  • 19,824
  • 17
  • 99
  • 186
victor
  • 1,626
  • 1
  • 14
  • 23
  • Perhaps host the git repo on the same network as the server? In Ruby, the deliverable is your code. – Matt Harrison Aug 10 '14 at 21:19
  • Isn't your production server on a different network? How can you access it without internet? – Kites Aug 11 '14 at 02:24
  • @Kites I was wondering the same but perhaps it's an internal app? – Matt Harrison Aug 11 '14 at 06:38
  • 1
    @Kites It's an internal app deployed and the server is hosted inside our company network. We will definetely not have internet access on staging and production, so we have to come up with a solution – victor Aug 11 '14 at 07:21

1 Answers1

3

Updated as of August 29th, 2014

It is possible to point capistrano to a local repository. I have done it.

You need a bare_repo to pull from, so first create a bare repository on the remote machine:

mkdir -p ~/projects/my_project.git
cd ~/projects/my_project.git
git init --bare

Then you need to somehow push your code to that repo. You can push via an ssh tunnel, or you can zip your working repo, copy it to the remote machine via scp, unzip it, and set that working directory to push to your new bare repo.

Then go back to your workstation and edit your deploy.rb file to point to the local repository you created on the remote machine.

set :repo_url, 'file:///path/to/bare_repo.git'

Then capistrano should be able to pull from the local git repository.

Optional: if capistrano is still looking for an online repo, then browse to your deployment directory on your remote server, and wipe out the repo folder:

cd /directory_where_i_am_deploying_to/
rm -rf repo
Maximus
  • 1,417
  • 15
  • 19
  • 2
    Just finished a full deployment without internet. The next issue was getting past bundle install, but I could package my gems into my vendor/cache directory, commit those to the repo, and in my deploy.rb file on my workstation I set this line: `set :bundle_flags, "--deployment --local"`. Then bundler didn't look to the internet for any gems. It worked! – Maximus Sep 03 '14 at 21:45