2023-10-15 16:47:24 -07:00
|
|
|
#!/bin/bash -e
|
2026-05-06 13:28:16 -04:00
|
|
|
set -e
|
2023-09-30 10:32:08 -07:00
|
|
|
|
2024-06-09 09:42:10 -07:00
|
|
|
# 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
|
2023-09-30 10:32:08 -07:00
|
|
|
|
2026-05-06 13:28:16 -04:00
|
|
|
# This prevents "A server is already running" errors if a previous container crashed.
|
|
|
|
|
if [ -f tmp/pids/server.pid ]; then
|
|
|
|
|
rm -f tmp/pids/server.pid
|
|
|
|
|
fi
|
|
|
|
|
|
2023-10-15 16:47:24 -07:00
|
|
|
# NOTE: Enable this as you need to get migrations working in your deployed
|
|
|
|
|
# (i.e. Production) environments. Match the condition check to what you have in
|
|
|
|
|
# the Dockerfile CMD. I use puma in the production.Dockerfile as that's the
|
|
|
|
|
# recommended option by the Puma team (https://github.com/puma/puma#rails), but
|
|
|
|
|
# the default Rails Dockerfile uses `./bin/rails server`
|
2024-06-09 09:42:10 -07:00
|
|
|
|
2026-05-06 13:28:16 -04:00
|
|
|
echo "starting puma server..."
|
2024-06-09 09:42:10 -07:00
|
|
|
|
2026-05-06 13:28:16 -04:00
|
|
|
# If running the rails server then create or migrate existing database
|
|
|
|
|
if [ "${1}" == "bundle" ] && [ "${2}" == "exec" ] && [ "${3}" == "puma" ]; then
|
|
|
|
|
./bin/rails db:migrate
|
|
|
|
|
fi
|
2023-09-30 11:39:51 -07:00
|
|
|
|
2023-10-15 16:47:24 -07:00
|
|
|
exec "${@}"
|