Method: Kowl::Docker#docker_app_command

Defined in:
lib/kowl/docker.rb

#docker_app_command(database, skip_sidekiq = false) ⇒ String

Generate the command for the application service in the applications docker-compose file

Parameters:

  • database (String)

    the specific database the application will be running on

  • skip_sidekiq (Boolean) (defaults to: false)

    if the application will skip using sidekiq

Returns:

  • (String)

    the CMD entry for applications service entry in the docker-compose file



236
237
238
239
240
241
242
243
244
245
246
247
248
249
# File 'lib/kowl/docker.rb', line 236

def docker_app_command(database, skip_sidekiq = false)
  db_str = docker_compose_database_string(database)
  joined_cmd_str = "#{docker_port_watcher(database, skip_sidekiq)}#{db_str}".strip
  # This is used in case the app is generated with --database=sqlite && --skip_sidekiq
  # => Thus meaning it doesn't to wait on a database and redis to connect to container before running it
  joined_cmd_str = joined_cmd_str.blank? ? '' : joined_cmd_str

  cmd_str = <<~CMD_STR
    #{joined_cmd_str}
    rm -rf /app/tmp/pids/server.pid /app/.local >/dev/null 2>&1 &&
    bundle exec rails s -p 3000 -b 0.0.0.0
  CMD_STR
  optimize_indentation(cmd_str, 13).strip
end