diff --git a/Dockerfile b/Dockerfile index b6d4f04..4d2a34d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -68,4 +68,7 @@ HEALTHCHECK --interval=15s --timeout=3s --start-period=0s --start-interval=5s -- CMD curl -f http://localhost:3000/up || exit 1 # Start the server by default, this can be overwritten at runtime EXPOSE 3000 -CMD ["./bin/rails", "server"] + +# The default Rails Dockerfile uses `./bin/rails server`, but when using Puma, +# they recommend using bundle exec puma. ref: https://github.com/puma/puma#rails +CMD ["bundle", "exec", "puma", "-C", "config/puma.rb"] diff --git a/bin/docker-entrypoint b/bin/docker-entrypoint index 1308e63..c96f9da 100755 --- a/bin/docker-entrypoint +++ b/bin/docker-entrypoint @@ -1,16 +1,22 @@ #!/bin/bash -e -echo "entrypoint" -echo "${*}" +# 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 # 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` -# -# If running the rails server then create or migrate existing database -# if [ "${*}" == "./bin/rails server" ]; then + +# echo "${1}" +# echo "${2}" +# echo "${3}" + +# # If running the rails server then create or migrate existing database +# if [ "${1}" == "bundle" ] && [ "${2}" == "exec" ] && [ "${3}" == "puma" ]; then # ./bin/rails db:prepare # fi