Skip to content

Commit c508cf5

Browse files
arampricerobdimsdale
authored andcommitted
🐞 fix value passed to --env
The rack environment is hard-coded to the value `RACK_ENV=production` which appears to be a conflation of setting an ENV variable, and passing the value value via the `--env` flag to `rackup`. This commit makes two changes: 1. The value passed to the flag `--env` is now `production`, not `RACK_ENV=production`, and changes to the associated tests. 2. The value `production`, while still hard-coded, is interpolated into the process args. This should make it easier to make the value dynamic in the future. See #281 Addresses #355
1 parent ca5248a commit c508cf5

5 files changed

Lines changed: 10 additions & 10 deletions

File tree

build.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ func Build(logger scribe.Emitter) packit.BuildFunc {
4343
}
4444
logger.Debug.Break()
4545

46-
// Use RACK_ENV=production since Rack v1.6.0+ defaults the host to local host in development mode (default)
46+
// Hardcode `--env production` since Rack v1.6.0+ defaults the host to local host in development mode (default)
4747
// The order of precedence in setting the port is:
4848
// 1. the $PORT variable if it is set
4949
// 2. A port listed in config.ru with the -p or --port flag
5050
// 3. 1 and 2 are not met, and the fallback port is set to the default of 9292.
51-
args := fmt.Sprintf(`bundle exec rackup --env RACK_ENV=production -p "${PORT:-%s}"`, port)
51+
args := fmt.Sprintf(`bundle exec rackup --env %s -p "${PORT:-%s}"`, "production", port)
5252
processes := []packit.Process{
5353
{
5454
Type: "web",

build_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) {
8181
{
8282
Type: "web",
8383
Command: "bash",
84-
Args: []string{"-c", `bundle exec rackup --env RACK_ENV=production -p "${PORT:-9292}"`},
84+
Args: []string{"-c", `bundle exec rackup --env production -p "${PORT:-9292}"`},
8585
Default: true,
8686
Direct: true,
8787
},
@@ -126,7 +126,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) {
126126
{
127127
Type: "web",
128128
Command: "bash",
129-
Args: []string{"-c", `bundle exec rackup --env RACK_ENV=production -p "${PORT:-3000}"`},
129+
Args: []string{"-c", `bundle exec rackup --env production -p "${PORT:-3000}"`},
130130
Default: true,
131131
Direct: true,
132132
},
@@ -175,7 +175,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) {
175175
{
176176
Type: "web",
177177
Command: "bash",
178-
Args: []string{"-c", `bundle exec rackup --env RACK_ENV=production -p "${PORT:-3000}"`},
178+
Args: []string{"-c", `bundle exec rackup --env production -p "${PORT:-3000}"`},
179179
Default: true,
180180
Direct: true,
181181
},

integration/config_port_app_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ func testConfigPortApp(t *testing.T, context spec.G, it spec.S) {
8484
" config.ru specifies a port: 3000",
8585
"",
8686
" Assigning launch processes:",
87-
` web (default): bash -c bundle exec rackup --env RACK_ENV=production -p "${PORT:-3000}"`,
87+
` web (default): bash -c bundle exec rackup --env production -p "${PORT:-3000}"`,
8888
))
8989

9090
Eventually(func() string {
@@ -133,7 +133,7 @@ func testConfigPortApp(t *testing.T, context spec.G, it spec.S) {
133133
MatchRegexp(fmt.Sprintf(`%s \d+\.\d+\.\d+`, settings.Buildpack.Name)),
134134
" Writing start command",
135135
" Assigning launch processes:",
136-
` web (default): bash -c bundle exec rackup --env RACK_ENV=production -p "${PORT:-3000}"`,
136+
` web (default): bash -c bundle exec rackup --env production -p "${PORT:-3000}"`,
137137
))
138138

139139
Eventually(func() string {

integration/simple_app_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func testSimpleApp(t *testing.T, context spec.G, it spec.S) {
8181
MatchRegexp(fmt.Sprintf(`%s \d+\.\d+\.\d+`, settings.Buildpack.Name)),
8282
" Writing start command",
8383
" Assigning launch processes:",
84-
` web (default): bash -c bundle exec rackup --env RACK_ENV=production -p "${PORT:-9292}"`,
84+
` web (default): bash -c bundle exec rackup --env production -p "${PORT:-9292}"`,
8585
))
8686
})
8787
})
@@ -117,7 +117,7 @@ func testSimpleApp(t *testing.T, context spec.G, it spec.S) {
117117
MatchRegexp(fmt.Sprintf(`%s \d+\.\d+\.\d+`, settings.Buildpack.Name)),
118118
" Writing start command",
119119
" Assigning launch processes:",
120-
` web (default): bash -c bundle exec rackup --env RACK_ENV=production -p "${PORT:-9292}"`,
120+
` web (default): bash -c bundle exec rackup --env production -p "${PORT:-9292}"`,
121121
))
122122
})
123123
})

integration/sinatra_app_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func testSinatraApp(t *testing.T, context spec.G, it spec.S) {
8080
MatchRegexp(fmt.Sprintf(`%s \d+\.\d+\.\d+`, settings.Buildpack.Name)),
8181
" Writing start command",
8282
" Assigning launch processes:",
83-
` web (default): bash -c bundle exec rackup --env RACK_ENV=production -p "${PORT:-9292}"`,
83+
` web (default): bash -c bundle exec rackup --env production -p "${PORT:-9292}"`,
8484
))
8585
})
8686
})

0 commit comments

Comments
 (0)