Skip to content

Commit

Permalink
Merge pull request #42 from heroku/malax/java-function-fixes
Browse files Browse the repository at this point in the history
Java functions fixes
  • Loading branch information
Malax authored Feb 4, 2021
2 parents f0b47d9 + 4125d70 commit 1795b7d
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 2 deletions.
6 changes: 6 additions & 0 deletions buildpacks/jvm-function-invoker/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Added
* Support for the `PORT` environment variable at runtime for setting the HTTP port

### Fixed
* When using an older version of `pack`, the function layer might be incorrectly restored, causing errors
"directory not empty" during function detection. A workaround has been added.

## [0.2.1] 2021/02/03
### Changed
Expand Down
9 changes: 8 additions & 1 deletion buildpacks/jvm-function-invoker/bin/build
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@ log::cnb::header "Detecting function"

function_bundle_layer_dir="${layers_dir}/function-bundle"
function_bundle_toml="${function_bundle_layer_dir}.toml"

# Workaround (Feb 2021): Benny 1.0.3 has a bug that restores this layer regardless of the cache setting.
if [[ -d "${function_bundle_layer_dir}" ]]; then
rm -rf "${function_bundle_layer_dir}"
fi
# End workaround

mkdir -p "${function_bundle_layer_dir}"

cat >"${function_bundle_toml}" <<-EOF
Expand Down Expand Up @@ -151,5 +158,5 @@ log::cnb::info "Return type: $(log::cnb::bold "$(yj -t <"${bundle_toml}" | jq -r
cat >>"${layers_dir}/launch.toml" <<-EOF
[[processes]]
type = "web"
command = "java -jar ${runtime_layer_jar_path} serve ${function_bundle_layer_dir}"
command = "java -jar ${runtime_layer_jar_path} serve ${function_bundle_layer_dir} -p \${PORT:-8080}"
EOF
5 changes: 5 additions & 0 deletions buildpacks/jvm/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Changed
* Status headers are now bold

### Fixed
* `JAVA_HOME` will now be correctly set when using older versions of `pack`

## [0.1.2] 2021/01/22
### Changed
Expand Down
8 changes: 8 additions & 0 deletions buildpacks/jvm/bin/build
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,20 @@ else
install_certs "${jdkLayer}"
install_profile "${bpDir}" "${jdkLayer}/profile.d"
install_jdk_overlay "${jdkVersion}" "${jdkLayer}" "${appDir}"

mkdir -p "${jdkLayer}/env.build"
echo -n "${jdkLayer}" >"${jdkLayer}/env.build/JAVA_HOME"

info "JDK ${jdkVersion} installed"

jreLayerToml="$(bp_layer_metadata_create "true" "false" "false" "${jdkMetadata}")"
jreLayer="$(bp_layer_init "${layersDir}" "jre" "${jreLayerToml}")"
install_jre "${jdkLayer}" "${jreLayer}"
install_certs "${jreLayer}"
install_profile "${bpDir}" "${jreLayer}/profile.d"

mkdir -p "${jreLayer}/env.launch"
echo -n "${jreLayer}" >"${jreLayer}/env.launch/JAVA_HOME"

info "JRE ${jdkVersion} installed"
fi
2 changes: 1 addition & 1 deletion buildpacks/jvm/lib/v3/common.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash

status() {
local color="\033[0;35m"
local color="\033[1;35m"
local no_color="\033[0m"
echo -e "\n${color}[${1:-""}]${no_color}"
}
Expand Down

0 comments on commit 1795b7d

Please sign in to comment.