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

Running multiple commands in entrypoint #52

Closed
imaia opened this issue Dec 27, 2016 · 5 comments
Closed

Running multiple commands in entrypoint #52

imaia opened this issue Dec 27, 2016 · 5 comments

Comments

@imaia
Copy link

imaia commented Dec 27, 2016

I'm trying to copy some files before running my entrypoint script. I tried something like this in my docker-compose.yml:

entrypoint: ["sh", "-c", "cp -r /usr/src/redmine/public/. /www/public/ && /docker-entrypoint.sh"]

But I'm getting a exit code 0. Suggestions?

@abcfy2
Copy link

abcfy2 commented Dec 28, 2016

You don't need to modify entrypoint, just set command.

    command:
      - /bin/sh
      - -c
      - |
          bundle config mirror.https://rubygems.org https://gems.ruby-china.org
          bundle exec rake redmine:plugins:migrate RAILS_ENV=production
          bundle exec rake tmp:cache:clear tmp:sessions:clear RAILS_ENV=production
          /docker-entrypoint.sh passenger start

YAML supports multiline string.

@jeanbza
Copy link

jeanbza commented Aug 18, 2017

Awesome solution @abcfy2

@tianon
Copy link
Member

tianon commented Apr 24, 2018

Closing, given the excellent solution posted above. 👍

(The only change I'd personally make is adding exec before the invocation of /docker-entrypoint.sh to ensure the outer shell process gets ditched and Redmine properly becomes PID 1.)

@tianon tianon closed this as completed Apr 24, 2018
@abcfy2
Copy link

abcfy2 commented Apr 25, 2018

No problem. Because the last line of /docker-entrypoint.sh is exec "$@", so this script will ensure Redmine become PID 1.

@jmdxy
Copy link

jmdxy commented Nov 12, 2020

/bin/sh: 1: bundle: not found
how to fix?

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

No branches or pull requests

5 participants