LoginSignup
0
0

More than 5 years have passed since last update.

docker-composeやesc-cli composeのcommandでデーモン起動したいシェルコマンドを叩くときはstart-stop-daemonが便利じゃないかという話

Last updated at Posted at 2018-06-02

最近になってやっとEC2原人からコンテナ猿人になりつつある俺です。
1コンテナ1プロセスな原則に逆らわなきゃいけないことがでてきてしまったとき
bash -c を改行しながら書くと可読性が向上しますよねと。

で、そのときに&起動すると構文エラーになるので、
start-stop-daemon先生を使って俺の最愛のシェルコマンドをダエモンにして、
最後に実行するシェルコマンドをフロントエンド起動してDockerコンテナを動かしましょう。
という話です。

ubuntuベースなimageで叩いた例です。
alpineとかもっと軽量ミニ四駆なlinuxをベースにしてる場合はstart-sop-daemonがあるのかは知らんですよ。

yarn watchしつつRailsを動かしたい例

  • docker-compose.yml
 rails-app:
    image: orenosaikyouime-ji:latest
    command: >
      /bin/bash -xc 
      "start-stop-daemon --start --quiet --background --exec yarn -- --cwd /app/js  watch
      && bundle exec rails assets:precompile
      && bundle exec puma -C config/puma.rb"
    environment:
      ..省略..

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0