Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Capistrano deployment without internet access on server

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?

like image 446
victor Avatar asked Aug 10 '14 21:08

victor


1 Answers

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
like image 178
Maximus Avatar answered Oct 11 '22 01:10

Maximus