Skip to content

Commit 3f1189e

Browse files
authoredMar 13, 2025··
Fix docker run with arguments (#404)
Fixes an issue where `docker run` with a command was not working correctly. Before: ``` $ docker run --rm --entrypoint /cnb/lifecycle/launcher sample-app "echo 'hi'" hi ⛄️ 3.4.2 🚀 /Users/rschneeman/Documents/projects/work/buildpacks-ruby (main) $ docker run --rm sample-app "echo 'hi'" bash: echo 'hi': No such file or directory $ pack inspect sample-app | grep Processes: -A10 Processes: TYPE SHELL COMMAND ARGS WORK DIR web (default) bash -c bundle exec rackup --host "[::]" --port "${PORT:?Error: PORT env var is not set!}" /workspace ``` After: ``` $ cargo libcnb package && pack build sample-app \ --buildpack packaged/x86_64-unknown-linux-musl/debug/heroku_ruby \ --path buildpacks/ruby/tests/fixtures/default_ruby --clear-cache $ docker run --rm sample-app "echo 'hi'" hi ``` The root cause is that when you `docker run` something, it uses the default command and uses the arguments you provide as arguments to that command. In this case we want the full shell, so the command needs to be `bash -c <arguments>` instead of `bash <arguments>`.
1 parent 8a3ef48 commit 3f1189e

File tree

2 files changed

+19
-21
lines changed

2 files changed

+19
-21
lines changed
 

‎buildpacks/ruby/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Fixed
11+
12+
- The `docker run` command no longer requires an entrypoint when using default processes provided by `heroku/ruby` directly (and not the `heroku/procfile` buildpack) ([#404](https://github.com/heroku/buildpacks-ruby/pull/404))
13+
1014
## [6.0.0] - 2025-03-12
1115

1216
### Changed

‎buildpacks/ruby/src/steps/get_default_process.rs

+15-21
Original file line numberDiff line numberDiff line change
@@ -69,32 +69,26 @@ fn detect_web(gem_list: &GemList, app_path: &Path) -> WebProcess {
6969
}
7070

7171
fn default_rack() -> Process {
72-
ProcessBuilder::new(process_type!("web"), ["bash"])
73-
.args([
74-
"-c",
75-
&[
76-
"bundle exec rackup",
77-
"--host \"[::]\"",
78-
"--port \"${PORT:?Error: PORT env var is not set!}\"",
79-
]
80-
.join(" "),
81-
])
72+
ProcessBuilder::new(process_type!("web"), ["bash", "-c"])
73+
.args([[
74+
"bundle exec rackup",
75+
"--host \"[::]\"",
76+
"--port \"${PORT:?Error: PORT env var is not set!}\"",
77+
]
78+
.join(" ")])
8279
.default(true)
8380
.build()
8481
}
8582

8683
fn default_rails() -> Process {
87-
ProcessBuilder::new(process_type!("web"), ["bash"])
88-
.args([
89-
"-c",
90-
&[
91-
"bin/rails server",
92-
"--binding \"[::]\"",
93-
"--port \"${PORT:?Error: PORT env var is not set!}\"",
94-
"--environment \"$RAILS_ENV\"",
95-
]
96-
.join(" "),
97-
])
84+
ProcessBuilder::new(process_type!("web"), ["bash", "-c"])
85+
.args([[
86+
"bin/rails server",
87+
"--binding \"[::]\"",
88+
"--port \"${PORT:?Error: PORT env var is not set!}\"",
89+
"--environment \"$RAILS_ENV\"",
90+
]
91+
.join(" ")])
9892
.default(true)
9993
.build()
10094
}

0 commit comments

Comments
 (0)
Please sign in to comment.