heroku-buildpack-freetds

by rails-sqlserver

GitHub Readme.md

heroku-buildpack-freetds

This is a Heroku buildpack for vendoring the FreeTDS binaries into your project.

Note on Heroku config

Optionally, set the FreeTDS version in a Heroku config like this:

heroku config:set FREETDS_VERSION=1.00.109

Make sure the version you're referencing exists on as a .tar.gz file on the FreeTDS releases.

See load_env_vars in bin/compile for additional configurable variables.

You may also force the buildpack to rebuild the binary. This may be necessary when updating the buildpack.

heroku config:set FREETDS_REBUILD=true

Just don't forget, after a successful release, to unset it.

heroku config:unset FREETDS_REBUILD

How it works

Rather than pulling down binary dependencies from a package manager and extracting them into place, this buildpack compiles FreeTDS from source the first time an app is built with it. The compiled binaries are cached for future builds, so this penalty is only incurred once.

This has the downside of a (potentially very long) deploy time for the first push, with the benefit of a less-fragile build product that's somewhat less likely to break due to platform and dependency shifts. Or at least, that's the hope!

Stack compatibility

This buildpack is tested primarily against the heroku-22 stack.

Allows for usage of TinyTDS on Heroku.

Usage

This is used alongside the Ruby buildpack.

It may be useful to load any client libraries as part of the release task to ensure the libraries linked correctly. For example, in a ruby app, you may add to the Procfile: release: bundle exec ruby -e "p(require 'tiny_tds')"

Install

Use master

heroku buildpacks:set --index 1 https://github.com/rails-sqlserver/heroku-buildpack-freetds

or use a stable tag, like v1.1.5

heroku buildpacks:set --index 1 https://github.com/rails-sqlserver/heroku-buildpack-freetds#v1.1.5

Changelog

  • HEAD. Diff
  • 1.1.5 Fix env var escaping for compatibility with other buildpacks Diff
  • 1.1.4 Buggy version of 1.1.5.
  • 1.1.3 Update to support Heroku 22 ssl version Diff
  • 1.1.2 Update FREETDS_VERSION from 1.00.21 to 1.00.109; Get source from https. Diff
  • 1.1.1 Fixed build linking. Diff
  • 1.1.0 Some improvements, including logging and env var FREETDS_REBUILD. Diff
  • 1.0.0 First stable release. Diff

Debugging

From 'heroku run bash'.

Print FreeTDS build logs to the screen:

for file in freetds/build_log-*; do echo -e "\n\n----------------------- $file------------------\n\n"; cat "$file"; done

Print TinyTDS build logs to the screen:

# change env vars as needed
( export TINY_TDS_VERSION="2.1.0"; export RUBY_PATH_VERSION="2.5.3"; for cmd in "ld /app/vendor/bundle/ruby/2.5.0/gems/tiny_tds-${TINY_TDS_VERSION}/lib/tiny_tds/tiny_tds.so" \
"cat /app/vendor/bundle/ruby/${RUBY_PATH_VERSION}/gems/tiny_tds-${TINY_TDS_VERSION}/ext/tiny_tds/Makefile" \
"cat /app/vendor/bundle/ruby/${RUBY_PATH_VERSION}/extensions/x86_64-linux/${RUBY_PATH_VERSION}-static/tiny_tds-${TINY_TDS_VERSION}/gem_make.out" \
"cat   /app/vendor/bundle/ruby/${RUBY_PATH_VERSION}/extensions/x86_64-linux/${RUBY_PATH_VERSION}-static/tiny_tds-${TINY_TDS_VERSION}/mkmf.log" ; do
echo -e "\n\n----------------------- $cmd------------------\n\n"; eval "$cmd"; done ; )

Connection Timeout

If you receive connection timeout errors (e.g. "Adaptive Server connection failed"), consider whether TLS/gnutls is interacting poorly with heroku or the server where your mssql server lives. You can set the environment variable heroku config:set USE_GNUTLS=" " and temporarily set heroku config:set FREETDS_REBUILD=true to rebuild the code using TLS. See FreeTDS/freetds#336 for more information.

License

'heroku-buildpack-freetds' is distributed under the MIT license. FreeTDS http://www.freetds.org/ which is licensed under the GNU LGPL license at http://www.gnu.org/licenses/lgpl-2.0.html