Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow use of Heroku config for ImageMagick version #16

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Allow use of Heroku config for ImageMagick version #16

wants to merge 3 commits into from

Conversation

francispotter
Copy link

Allows you to set the IMAGE_MAGICK_VERSION in Heroku config and it will work.

(Previous implementation assumed that config settings appear as environment variables to build packs, but they are actually exposed in a set of files in the ENV_VAR parameter, as per Heroku docs.)

Copy link

@jayzes jayzes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One comment on the conditional, but looks great to me otherwise - thanks for the PR!

Have you tried this out on a live app yet?

VENDOR_DIR="$BUILD_DIR/vendor"
mkdir -p $VENDOR_DIR
INSTALL_DIR="$VENDOR_DIR/imagemagick"
mkdir -p $INSTALL_DIR
IMAGE_MAGICK_VERSION="${IMAGE_MAGICK_VERSION:-6.9.5-10}"
if [ -d $ENV_DIR ]; then
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we collapse this conditional and the one two lines down together into a single -f test? I think that would also make it so we only have to specify the default version once.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did run it on a live app, and it worked to install the right version of ImageMagick. But the app failed because ImageMagick requires some version-specific configuration setup that I couldn't figure out how to add via the buildback. So I ended up using a different approach (Linux 'file' command instead of 'identify') and abandoned this direction.

Copy link

@bf4 bf4 Jan 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

like

[ -f "${ENV_DIR}/IMAGE_MAGICK_VERSION" ] && export "IMAGE_MAGICK_VERSION=$(cat "${ENV_DIR}/IMAGE_MAGICK_VERSION")"
IMAGE_MAGICK_VERSION="${IMAGE_MAGICK_VERSION:-6.9.5-10}"

I wrote a function for this:

load_env_vars() {
  local env_var; env_var="${1:-}"
  until [ -z "$env_var" ]; do [ -f "$ENV_DIR/$env_var" ] && export "$env_var=$(cat "$ENV_DIR/$env_var")"; shift ; env_var="${1:-}" ; done
}
load_env_vars "IMAGE_MAGICK_VERSION" "OTHER_THING"

@joshRpowell
Copy link

@jayzes this heroku-buildpack-jemalloc fork accommodates both stack and version. https://github.com/gaffneyc/heroku-buildpack-jemalloc/blob/master/bin/compile

heroku-18 was just released gaffneyc/heroku-buildpack-jemalloc@28198d9

perhaps this buildpack could incorporate some of the progress made there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants