Skip to content

Instantly share code, notes, and snippets.

@johnbeynon
Last active May 24, 2022 16:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnbeynon/a138d7b38bc45af62495a41c74809f07 to your computer and use it in GitHub Desktop.
Save johnbeynon/a138d7b38bc45af62495a41c74809f07 to your computer and use it in GitHub Desktop.
# Sample render-build.sh
#
# Downloads and compiles FreeTDS and adds config so that Bundler can compile the native Gem
#
# Usage
# store in bin/render-build.sh
# chmod +x bin/render-build.sh
#
# Configure Render service to use as buildCommnd
# use via the buildCommand `/bin/render-build.sh`
#
# OR
# via render.yaml
# `buildCommand: "./bin/render-build.sh"`
#!/usr/bin/env bash
# exit on error
set -o errexit
# Download FreeTDS and compile if it's not in the cache
if [[ ! -d $XDG_CACHE_HOME/freetds ]]; then
echo "...Downloading and compiling FreeTDS"
mkdir -p ~/tmp
wget -P ~/tmp ftp://ftp.freetds.org/pub/freetds/stable/freetds-1.3.10.tar.gz
cd ~/tmp
tar -xzf freetds-1.3.10.tar.gz
cd freetds-1.3.10
autoconf
./configure --prefix=$XDG_CACHE_HOME/freetds
make
make install
cd $HOME/project/src # Make sure we return to where we were
else
echo "...Using FreeTDS from build cache"
fi
# Set a bundler config option with the path to the freeTDS directory
bundle config build.tiny_tds --with-freetds-dir=$XDG_CACHE_HOME/freetds/
# We always want these run
bundle config set --local without 'development test'
bundle install
# Only run these tasks on the web service
if [ "$RENDER_SERVICE_TYPE" = 'web' ]
then
echo "Service type is WEB..."
echo "...running rake assets:precompile"
bundle exec rake assets:precompile
# bundle exec rake assets:clean
echo "...running rake db:migrate"
bundle exec rake db:migrate
else
echo "Not a web process so nothing to do here."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment