Created
August 24, 2022 15:03
-
-
Save BigAlRender/935bd05b4155a3d1bda275a8cc991b7e to your computer and use it in GitHub Desktop.
libmagic config for ruby-filemagic gem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# NOTES | |
# Sample render-build.sh | |
# | |
# Symlinks libmagic and downloads headers. Then 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 build command `./bin/render-build.sh` | |
# | |
# OR | |
# via render.yaml | |
# `buildCommand: "./bin/render-build.sh"` | |
# END NOTES | |
#!/usr/bin/env bash | |
# exit on error | |
set -o errexit | |
LIBMAGIC_DIR=$XDG_CACHE_HOME/libmagic | |
# Download/setup libmagic headers if it's not in the cache | |
if [[ ! -d $XDG_CACHE_HOME/libmagic ]]; then | |
echo "...Downloading libmagic headers" | |
mkdir -p $LIBMAGIC_DIR/include/file | |
wget -P $LIBMAGIC_DIR/include https://raw.githubusercontent.com/NetsoftHoldings/heroku-buildpack-magic/master/include/magic.h | |
wget -P $LIBMAGIC_DIR/include/file https://raw.githubusercontent.com/NetsoftHoldings/heroku-buildpack-magic/master/include/file/file.h | |
mkdir $LIBMAGIC_DIR/lib | |
ln -s /usr/lib/x86_64-linux-gnu/libmagic.so.1.0.0 $LIBMAGIC_DIR/lib/libmagic.so | |
else | |
echo "...Using libmagic from build cache" | |
fi | |
# Set a bundler config option with the path to the freeTDS directory | |
bundle config build.ruby-filemagic --with-magic-dir=$LIBMAGIC_DIR | |
# We always want these run | |
#bundle config set --local without 'development test' | |
bundle install |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment