Skip to content

cf run-task failing for docker-based apps #1376

Open
@rahearn

Description

@rahearn

Issue

A simple app built with Ruby on Rails and deployed to cloud.gov via docker image runs fine, but cf run-tasks and cf ssh do not work without workarounds.

Context

It appears that the PATH gets messed up for cf run-tasks and cf ssh while the actual running app is fine. On an example app:

cf run-tasks cf-test "bundle exec rake db:migrate" fails, but

cf run-task cf-test "export PATH=/usr/local/bundle/bin:/usr/local/bundle/gems/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin && cd /usr/src/app && bundle check --path vendor/bundle/ && bundle exec rake db:migrate"

works. The same PATH exporting and bundle check dance is required to run commands after using cf ssh APP_NAME

On further testing today, run-task might only require prepending the cd /usr/src/app (that path being the WORKDIR of the docker image) part to correctly run, though cf ssh requires the full setup before commands start being found.

Steps to Reproduce

A reproducing example app is at https://github.com/rahearn/cf-docker-test

The full docker build command used was:

docker build -t rcahearn/cf-test --build-arg RAILS_MASTER_KEY=809a1129e14e8e36f126c76dfce87e25 --build-arg BUILD_ENV=production --build-arg BUNDLE_WITHOUT="development test" .

Expected result

Tasks such as bundle exec rake db:migrate:status complete successfully.

Current result

Tasks such as bundle exec rake db:migrate:status fail with logs:

2019-06-14T09:09:24.14-0400 [APP/TASK/f180fd00/0] ERR Could not locate Gemfile or .bundle/ directory
2019-06-14T09:09:24.17-0400 [APP/TASK/f180fd00/0] OUT Exit status 10

Commands such as bundle exec rake db:migrate:status when run after sshing to app fail with:

root@f153f6fd-97a9-47ab-4a36-e9c8:/usr/src/app# bundle exec rake db:migrate:status
bash: bundle: command not found

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions