Issue 1255 server port sb fix#1256
Merged
ramonskie merged 3 commits intocloudfoundry:mainfrom May 4, 2026
Merged
Conversation
Apps with server.port set in application.yml would bind to the wrong port at startup, causing CF health checks to fail. Apps with a privileged port (< 1024, e.g. 443) would crash immediately with java.net.BindException: Permission denied. Mirrors the Ruby buildpack behaviour in spring_boot.rb release(). Fixes cloudfoundry#1255
…runtime WriteEnvFile writes the literal string "$PORT" to deps/0/env/SERVER_PORT. CF's launcher reads env files as plain text (no shell expansion), so Spring Boot received the literal string "$PORT" as the port, which is invalid and ignored, leaving server.port from application.yml in effect. Replace with WriteProfileD which writes a bash profile.d script that is *sourced* at container start — so $PORT is expanded to the actual CF-assigned port number before Spring Boot initialises its embedded server. This fixes: - apps binding to a hardcoded port instead of the CF-assigned $PORT - java.net.BindException: Permission denied for privileged ports (e.g. 443)
Contributor
|
it seems there are more frameworks that have similar issues. |
| "JAVA_OPTS": "$JAVA_OPTS", | ||
| "SERVER_PORT": "$PORT", | ||
| if err := s.context.Stager.WriteEnvFile("JAVA_OPTS", "$JAVA_OPTS"); err != nil { | ||
| s.context.Log.Warning("Failed to set JAVA_OPTS: %s", err.Error()) |
Contributor
There was a problem hiding this comment.
isn't this interfering the java opts finalization here? Could have been an issue also prior to this change that was missed.
Contributor
There was a problem hiding this comment.
i really thought we handled all the old style writeEnvFile to writeProfileD but apparently not
Contributor
|
if you want you can combine this with #1262 |
Contributor
Author
|
should I do something to combine it with #1262? or will that merge on top of this PR? |
Contributor
|
If we merge this first it will just be fine as well |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fixes #1255