Heroku: Using external mount in local filesystem
Asked Answered
J

2

5

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?

Joab answered 10/12, 2012 at 6:18 Comment(1)
Heroku's filesystem is not read only. However, writing to it with anything other than extremely temporary data will indeed cause issues due to their scalability requirements.Tahsildar
J
2

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.

Joab answered 27/2, 2013 at 2:16 Comment(0)
P
1

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

Partain answered 22/6, 2013 at 19:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.