heroku / cnb-shim

This is a shim to run old buildpacks as Cloud Native Buildpacks
MIT License
1 stars 0 forks source link

Is it bug? #11

Closed choijunwoo closed 4 years ago

choijunwoo commented 4 years ago

When i use heroku-buildpack-gradle shim doesn't seem to be able to automatically inject the startup cmd for spring boot app. I solved it like below but I wonder if this is intended.

jkutner commented 4 years ago

@choijunwoo yes, this looks like a bug. Thank you for investigating it! If you don't mind, I will switch this to "Ready for review" and get it shipped. We'll also add some tests for this.

Thanks again.

jkutner commented 4 years ago

@choijunwoo can you confirm that using the buildpack URL https://cnb-shim-staging.herokuapp.com/v1/heroku/gradle works now?

choijunwoo commented 4 years ago

@jkutner No. There is still no value in the process label.

      "Labels": {
        "io.buildpacks.build.metadata": "{\"processes\":[],\"buildpacks\":[{\"id\":\"heroku/gradle\",\"version\":\"0.1\"},{\"id\":\"heroku/procfile\",\"version\":\"0.5\"}],\"bom\":null,\"launcher\":{\"version\":\"0.6.1\",\"source\":{\"git\":{\"repository\":\"https://github.com/buildpacks/lifecycle\",\"commit\":\"d930835\"}}}}",
        "io.buildpacks.lifecycle.metadata": "{\"app\":[{\"sha\":\"sha256:8a5371209e82dc8b984e1ef7a4c81d95ac246e68dd06550d34751df9c02bd000\"}],\"config\":{\"sha\":\"sha256:45e4839cdef39927e0dc3da32e9b3d635847092a1e4cd60b51fed0e8ed3a42e2\"},\"launcher\":{\"sha\":\"sha256:a9e8a84f59d684926f7dbc105ffc7fc7a39eb87fa25c41526f2fef6ec8220737\"},\"buildpacks\":[{\"key\":\"heroku/gradle\",\"version\":\"0.1\",\"layers\":{\"profile\":{\"sha\":\"sha256:bf96c1199191cea7a6269c0ef1b21267c51f9fb3f2a22bffe9eeec74567f88aa\",\"data\":null,\"build\":false,\"launch\":true,\"cache\":false}}},{\"key\":\"heroku/procfile\",\"version\":\"0.5\",\"layers\":{}}],\"runImage\":{\"topLayer\":\"sha256:7a3a948efe9f8c3d7427291a4b5b87ed978c3bd43d61680c4f23ee2e737bd082\",\"reference\":\"aa10256106fe269f33340fafacc3a00a2fc7ed956f58bd2689245015c5232181\"},\"stack\":{\"runImage\":{\"image\":\"/heroku-pack:18\"}}}",
        "io.buildpacks.stack.id": "heroku-18"
      }
jkutner commented 4 years ago

@choijunwoo did you test your fork of the shim and it worked? I'm wondering if the proposed change doesn't actually fix the problem or if I didn't something wrong in the merge

jkutner commented 4 years ago

it could also be something wrong in the gradle buildpack

choijunwoo commented 4 years ago

@jkutner https://cnb-shim-staging.herokuapp.com/v1/heroku/gradle Um.. build script still seems to be the old code. Could you check this? Thank you.

#!/usr/bin/env bash

# fail hard
set -o pipefail
# fail harder
set -eu

bp_dir=$(cd $(dirname $0)/..; pwd) # absolute path
source_dir="${bp_dir}/target"

layers_dir="${1:?}"
platform_dir="${2:?}"

# translate new stack ID to old stack ID
export STACK="$CNB_STACK_ID"

# copy the buildpack source into the target dir
target_dir="$(mktemp -d)/target"
cp -R "$source_dir" "$target_dir"
chmod -R +w "$target_dir"

# create a shim cache layer
cache_dir="${layers_dir}/shim"
mkdir -p "${cache_dir}"
echo "cache = true" > ${layers_dir}/shim.toml

"${target_dir}/bin/compile" "$(pwd)" "${cache_dir}" "${platform_dir}/env"

# copy profile.d scripts into a layer so they will be sourced
if [[ -d .profile.d ]]; then
    profile_dir="${layers_dir}/profile"
    mkdir -p "${profile_dir}/profile.d"
    cp .profile.d/* "${profile_dir}/profile.d/"
    echo "launch = true" > "${profile_dir}.toml"
fi

if [[ -f "${target_dir}/export" ]]; then
  echo "build = true" >> "${profile_dir}.toml"
  mkdir -p "${profile_dir}/env.build/"
  "${bp_dir}/bin/exports" "${target_dir}/export" "${platform_dir}" "${profile_dir}/env.build/"
fi

# run bin/release, read Procfile, and generate launch.toml
"${bp_dir}/bin/release" "${target_dir}" "${layers_dir}" "${platform_dir}"
jkutner commented 4 years ago

@choijunwoo whoops, i don't think your change was deploy. Please try that URL again (sorry!)

choijunwoo commented 4 years ago

@jkutner Sorry for late. I have confirmed that the command is in the Process label. Thank you.

"Labels": {
  "io.buildpacks.build.metadata": "{\"processes\":[{\"type\":\"web\",\"command\":\"java -Dserver.port=$PORT $JAVA_OPTS -jar build/libs/*.jar\",\"args\":null,\"direct\":false}],\"buildpacks\":[{\"id\":\"heroku/gradle\",\"version\":\"0.1.2\"},{\"id\":\"heroku/procfile\",\"version\":\"0.5\"}],\"bom\":null,\"launcher\":{\"version\":\"0.6.1\",\"source\":{\"git\":{\"repository\":\"https://github.com/buildpacks/lifecycle\",\"commit\":\"d930835\"}}}}",
  "io.buildpacks.lifecycle.metadata": "{\"app\":[{\"sha\":\"sha256:3a812f3ed6802701862eea17a945480d55147f42979de7ef77b773e23b954eaf\"}],\"config\":{\"sha\":\"sha256:40192c4975b0cf035c4aa2cc24c66409372a5402658f2eee652d89a937e1a190\"},\"launcher\":{\"sha\":\"sha256:a9e8a84f59d684926f7dbc105ffc7fc7a39eb87fa25c41526f2fef6ec8220737\"},\"buildpacks\":[{\"key\":\"heroku/gradle\",\"version\":\"0.1.2\",\"layers\":{\"profile\":{\"sha\":\"sha256:45314c9e734206954b7e09ee7ce1f2e3975938657ddaae8dedc3c3b6b6df1e94\",\"data\":null,\"build\":false,\"launch\":true,\"cache\":false}}},{\"key\":\"heroku/procfile\",\"version\":\"0.5\",\"layers\":{}}],\"runImage\":{\"topLayer\":\"sha256:7a3a948efe9f8c3d7427291a4b5b87ed978c3bd43d61680c4f23ee2e737bd082\",\"reference\":\"aa10256106fe269f33340fafacc3a00a2fc7ed956f58bd2689245015c5232181\"},\"stack\":{\"runImage\":{\"image\":\"/heroku-pack:18\"}}}",
  "io.buildpacks.stack.id": "heroku-18"
}
jkutner commented 4 years ago

@choijunwoo great! sorry this was such a hassle. We'll make it available in the default buildpack on Monday.