Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Heroku: Using external mount in local filesystem

I know it's possible to mount an Amazon S3 bucket using Fuse (s3fs [or s3fsr ruby gem?]).

My case is specific to Heroku.

Heroku's filesystem is readonly for scalability and such, but is there a way to mount an amazon s3 in Heroku's filesystem?

In my case, I use Redmine on Heroku and would like to use Redmine's built-in git repository management to link code reviews to my issues. Redmine needs to clone the repository to a local directory, which is possible but not persistent on Heroku.

I would like Redmine to maintain a git repository on a mounted S3 bucket. Is this possible? If it was possible, how slow would that be? Are there any other alternatives to achieve this?

like image 433
Jim Avatar asked Nov 13 '22 15:11

Jim


2 Answers

I haven't found the perfect answer to my question but here's an OK workaround.

You can override the default Heroku boot script (and much more) by creating a file called Procfile at the root of your project.

Here's the Procfile :

# run custom boot scirpt
web: sh /app/config/web-boot.sh

It tells Heroku that this script boots Redmine.

I'm using Bitbucket with a private repository, so I created a SSH key pair and placed them in 'config/ssh/'. Then, I added the Public key to my Bitbucket account's deploy keys and added Bitbucket's public Key to my 'config/ssh/know_hosts' file

Here's the 'config/web-boot.sh' file :

# move ssh keys
mkdir /app/.ssh
cp /app/config/ssh/* /app/.ssh/

# git clone code repos
mkdir /tmp/repos

# Do this for every repo you want to clone
git clone --bare ssh://[email protected]/[YOUR_ACCOUNT]/[YOUR_REPO].git /tmp/repos/[YOUR_REPO]
git --git-dir=/tmp/repos/[YOUR_REPO] remote add origin ssh://[email protected]/[YOUR_ACCOUNT]/[YOUR_REPO].git
git --git-dir=/tmp/repos/[YOUR_REPO] fetch origin

# run Unicorn http server
cd /app
bundle exec unicorn -p $PORT -c ./config/unicorn.rb

Then you can just add the Git repository to your Redmine project by specifying '/tmp/repos/[YOUR_REPO]'

You can use Redmine Bitbucket Hook plugin to pull changes to your repository when you push changes to Bitbucket.

It's not ideal to have a private key hoping around like this, but in my specific case, this key is unique to this app and is only used to gain readonly access to my code repository.

like image 58
Jim Avatar answered Nov 15 '22 05:11

Jim


Just notice that Heroku now run scripts in .profile.d/ at boot time.

https://devcenter.heroku.com/articles/profiled

For the You can also add a 'git push' post-commit hook (in .git/hooks/post-commit), which should push all changes to BitBucket after every local commit.

https://www.kernel.org/pub/software/scm/git/docs/githooks.html

like image 39
goofrider Avatar answered Nov 15 '22 04:11

goofrider