#!/bin/bash -e # Enable jemalloc for reduced memory usage and latency. if [ -z "${LD_PRELOAD+x}" ] && [ -f /usr/lib/*/libjemalloc.so.2 ]; then export LD_PRELOAD="$(echo /usr/lib/*/libjemalloc.so.2)" fi # If running the rails server then migrate existing database if [ "${1}" == "bundle" ] && [ "${2}" == "exec" ] && [ "${3}" == "puma" ]; then echo "running migrations..." ./bin/rails db:migrate fi rm -f /usr/src/app/tmp/pids/server.pid rm -rf /usr/local/bundle/cache/*.gem echo "bundle install..." bundle check || bundle install --jobs 4 exec "${@}"