Skip to content

Instantly share code, notes, and snippets.

@mrdanadams
Created June 22, 2013 01:34
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrdanadams/5835460 to your computer and use it in GitHub Desktop.
Save mrdanadams/5835460 to your computer and use it in GitHub Desktop.
Adding Geos and Proj4 support to Heroku using buildpacks
https://github.com/peterkeen/heroku-buildpack-vendorbinaries.git
https://github.com/aaronrenner/heroku-buildpack-rgeo-prep.git
https://github.com/kr/heroku-buildpack-inline.git
https://github.com/heroku/heroku-buildpack-ruby.git
https://s3.amazonaws.com/spacialdb/heroku/geos-3.3.8.tar.gz
https://s3.amazonaws.com/spacialdb/heroku/proj-4.8.0.tar.gz

Based on https://github.com/aaronrenner/heroku-buildpack-rgeo-prep but with support for existing applications.

General steps:

  1. Add the buildpacks and .vendor_urls
  2. Add the custom buildpack files under a new directory bin
  3. Run: heroku config:set LD_LIBRARY_PATH=/app/lib
  4. Deploy

You should see something like:

-----> Fetching custom git buildpack... done
-----> Multipack app detected
=====> Downloading Buildpack: https://github.com/peterkeen/heroku-buildpack-vendorbinaries.git
=====> Detected Framework: VendorBinaries
-----> Found a .vendor_urls file
       Vendoring https://s3.amazonaws.com/spacialdb/heroku/geos-3.3.8.tar.gz
       Vendoring https://s3.amazonaws.com/spacialdb/heroku/proj-4.8.0.tar.gz
=====> Downloading Buildpack: https://github.com/aaronrenner/heroku-buildpack-rgeo-prep.git
=====> Detected Framework: heroku-buildpack-rgeo-prep
-----> Removing cached .bundle/config
       Writing new .bundle/config
=====> Downloading Buildpack: https://github.com/kr/heroku-buildpack-inline.git
=====> Detected Framework: RGeoCleaner
-----> Removing all rgeo files to force compilation during bundling
-----> cleaning cache dir
/app/tmp/repo.git/.cache/vendor/bundle/ruby/1.9.1/cache/rgeo-activerecord-0.4.6.gem
/app/tmp/repo.git/.cache/vendor/bundle/ruby/1.9.1/cache/rgeo-0.3.20.gem
/app/tmp/repo.git/.cache/vendor/bundle/ruby/1.9.1/cache/rgeo-shapefile-0.2.3.gem
/app/tmp/repo.git/.cache/vendor/bundle/ruby/1.9.1/cache/rgeo-geojson-0.2.3.gem
/app/tmp/repo.git/.cache/vendor/bundle/ruby/1.9.1/specifications/rgeo-activerecord-0.4.6.gemspec
/app/tmp/repo.git/.cache/vendor/bundle/ruby/1.9.1/specifications/rgeo-shapefile-0.2.3.gemspec
/app/tmp/repo.git/.cache/vendor/bundle/ruby/1.9.1/specifications/rgeo-geojson-0.2.3.gemspec
/app/tmp/repo.git/.cache/vendor/bundle/ruby/1.9.1/specifications/rgeo-0.3.20.gemspec
/app/tmp/repo.git/.cache/vendor/bundle/ruby/1.9.1/gems/rgeo-shapefile-0.2.3
/app/tmp/repo.git/.cache/vendor/bundle/ruby/1.9.1/gems/rgeo-shapefile-0.2.3/lib/rgeo
/app/tmp/repo.git/.cache/vendor/bundle/ruby/1.9.1/gems/rgeo-shapefile-0.2.3/lib/rgeo-shapefile.rb
/app/tmp/repo.git/.cache/vendor/bundle/ruby/1.9.1/gems/rgeo-activerecord-0.4.6
/app/tmp/repo.git/.cache/vendor/bundle/ruby/1.9.1/gems/rgeo-activerecord-0.4.6/lib/rgeo
/app/tmp/repo.git/.cache/vendor/bundle/ruby/1.9.1/gems/rgeo-activerecord-0.4.6/lib/rgeo-activerecord.rb
/app/tmp/repo.git/.cache/vendor/bundle/ruby/1.9.1/gems/rgeo-geojson-0.2.3
/app/tmp/repo.git/.cache/vendor/bundle/ruby/1.9.1/gems/rgeo-geojson-0.2.3/lib/rgeo-geojson.rb
/app/tmp/repo.git/.cache/vendor/bundle/ruby/1.9.1/gems/rgeo-geojson-0.2.3/lib/rgeo
/app/tmp/repo.git/.cache/vendor/bundle/ruby/1.9.1/gems/rgeo-0.3.20
/app/tmp/repo.git/.cache/vendor/bundle/ruby/1.9.1/gems/rgeo-0.3.20/lib/rgeo
/app/tmp/repo.git/.cache/vendor/bundle/ruby/1.9.1/gems/rgeo-0.3.20/lib/rgeo.rb
=====> Downloading Buildpack: https://github.com/heroku/heroku-buildpack-ruby.git
=====> Detected Framework: Ruby/Rails

To test:

$ heroku run rails c
Running `rails c` attached to terminal... up, run.4936
Loading production environment (Rails 3.2.11)
irb(main):001:0> RGeo::Geos.supported?
=> true
irb(main):002:0> RGeo::CoordSys::Proj4.supported?
=> true
#!/bin/sh
# bin/compile <build-dir> <cache-dir>
echo "-----> Removing all rgeo files to force compilation during bundling"
echo "-----> cleaning cache dir"
find $2 -name '*rgeo*'
find $2 -name '*rgeo*' | xargs rm -rf
#!/bin/sh
echo "RGeoCleaner"
exit 0
#!/bin/sh
cat <<EOF
---
config_vars:
default_process_types:
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment