Skip to content
This repository has been archived by the owner on Feb 5, 2021. It is now read-only.

Make entrypoint RubyMine compatible. #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .docker/entrypoint
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

set +e
set -e

echo "⚙️ Testing DB connection"
timeout 300s waitfortcp "${RAILS_DB_HOST-db}" "${RAILS_DB_PORT-3306}"
Expand Down Expand Up @@ -29,4 +29,4 @@ fi
echo "➡️ Handing control over to '$*''"

# shellcheck disable=SC2068
exec bundle exec $@
exec bundle exec "$@"
Copy link
Member

@cimnine cimnine Nov 7, 2019

Choose a reason for hiding this comment

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

🤔 It was intentionally not quoted. Calling the script like .docker/entrypoint somecommand -with -some -arguments would result in a command like that:

exec bundle exec "somecommand -with -some -arguments"

I.e. bash won't split the string into multiple arguments, but pass it as one argument. Bundler would see the following arguments:

arg[0] = 'bundle'
arg[1] = 'exec'
arg[2] = 'somecommand -with -some -arguments'

Rather than without the quotes:

arg[0] = 'bundle'
arg[1] = 'exec'
arg[2] = 'somecommand'
arg[3] = '-with'
arg[4] = '-some'
arg[5] = '-arguments'

I'm not sure if the proposed change achieves what is intended.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried it just now in various quoting combinations, it works just fine like that (e.g. docker-compose run --rm app rails c and docker-compose run --rm app --keep-file-descriptors rails c gives me the rails shell). I think the first exec splits the arguments again, but couldn't find any documentation on it.

Without the quotes, RubyMine gets stuck at

Handing control over to 'sh -c /usr/local/bin/ruby /app/hitobito/bin/rails server -b 0.0.0.0 -p 3000 -e development''