Heroku: Using external mount in local filesystem

旧时模样 提交于 2019-12-04 09:21:58

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://git@bitbucket.org/[YOUR_ACCOUNT]/[YOUR_REPO].git /tmp/repos/[YOUR_REPO]
git --git-dir=/tmp/repos/[YOUR_REPO] remote add origin ssh://git@bitbucket.org/[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.

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!