Skip to content

Commit

Permalink
fix ruby function builds using the oss builders
Browse files Browse the repository at this point in the history
We didn't have an order group for the ruby functions framework scenario. This commit adds it and updates the acceptance tests to verify it is being used correctly.

PiperOrigin-RevId: 676540372
Change-Id: Ieba3ec2dbf2ad2919079aa6e28a18908b6ad1f23
  • Loading branch information
matthewrobertson authored and copybara-github committed Sep 19, 2024
1 parent d43f8f8 commit 12d541e
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 7 deletions.
4 changes: 4 additions & 0 deletions builders/gcp/base/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ builder(
name = "builder",
buildpacks = [
"//cmd/config/entrypoint:entrypoint.tgz",
"//cmd/utils/archive_source:archive_source.tgz",
"//cmd/utils/label:label_image.tgz",
"//cmd/utils/nginx:nginx.tgz",
"//cmd/config/flex:flex.tgz",
Expand Down Expand Up @@ -64,6 +65,7 @@ builder(
],
"ruby": [
"//cmd/ruby/missing_entrypoint:missing_entrypoint.tgz",
"//cmd/ruby/functions_framework:functions_framework.tgz",
"//cmd/ruby/rubygems:rubygems.tgz",
"//cmd/ruby/bundle:bundle.tgz",
"//cmd/ruby/rails:rails.tgz",
Expand All @@ -84,6 +86,7 @@ builder(
name = "google_22_builder",
buildpacks = [
"//cmd/config/entrypoint:entrypoint.tgz",
"//cmd/utils/archive_source:archive_source.tgz",
"//cmd/utils/label:label_image.tgz",
"//cmd/utils/nginx:nginx.tgz",
"//cmd/config/flex:flex.tgz",
Expand Down Expand Up @@ -141,6 +144,7 @@ builder(
],
"ruby": [
"//cmd/ruby/missing_entrypoint:missing_entrypoint.tgz",
"//cmd/ruby/functions_framework:functions_framework.tgz",
"//cmd/ruby/rubygems:rubygems.tgz",
"//cmd/ruby/bundle:bundle.tgz",
"//cmd/ruby/rails:rails.tgz",
Expand Down
1 change: 1 addition & 0 deletions builders/gcp/base/acceptance/acceptance.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const (
pythonMissingEntrypoint = "google.python.missing-entrypoint"
pythonWebserver = "google.python.webserver"
rubyBundle = "google.ruby.bundle"
rubyFF = "google.ruby.functions-framework"
rubyRails = "google.ruby.rails"
rubyRuntime = "google.ruby.runtime"
utilsNginx = "google.utils.nginx"
Expand Down
14 changes: 7 additions & 7 deletions builders/gcp/base/acceptance/ruby_fn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,29 +31,29 @@ func TestAcceptance(t *testing.T) {
{
Name: "function with dependencies",
App: "with_dependencies",
MustUse: []string{rubyRuntime, rubyBundle, entrypoint},
MustUse: []string{rubyRuntime, rubyBundle, rubyFF},
},
{
Name: "function with platform-specific dependencies",
App: "with_platform_dependencies",
MustUse: []string{rubyRuntime, rubyBundle, entrypoint},
MustUse: []string{rubyRuntime, rubyBundle, rubyFF},
},
{
Name: "function with runtime env var",
App: "with_env_var",
RunEnv: []string{"FOO=foo"},
MustUse: []string{rubyRuntime, rubyBundle, entrypoint},
MustUse: []string{rubyRuntime, rubyBundle, rubyFF},
},
{
Name: "function in fn_source file",
App: "with_fn_source",
RunEnv: []string{"FUNCTION_SOURCE=sub_dir/custom_file.rb"},
MustUse: []string{rubyRuntime, rubyBundle, entrypoint},
Env: []string{"GOOGLE_FUNCTION_SOURCE=sub_dir/custom_file.rb"},
MustUse: []string{rubyRuntime, rubyBundle, rubyFF},
},
{
Name: "function using framework older than 0.7",
App: "with_legacy_framework",
MustUse: []string{rubyRuntime, rubyBundle, entrypoint},
MustUse: []string{rubyRuntime, rubyBundle, rubyFF},
},
}

Expand All @@ -65,7 +65,7 @@ func TestAcceptance(t *testing.T) {
tc.Path = "/testFunction"
tc.Env = append(tc.Env,
"GOOGLE_RUNTIME_VERSION=3.1.*",
"GOOGLE_ENTRYPOINT=bundle exec functions-framework-ruby --target testFunction",
"GOOGLE_FUNCTION_TARGET=testFunction",
)

acceptance.TestApp(t, imageCtx, tc)
Expand Down
29 changes: 29 additions & 0 deletions builders/gcp/base/builder.toml
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ description = "Ubuntu 18 base image with buildpacks for .NET, Go, Java, Node.js,
id = "google.python.missing-entrypoint"
uri = "python/missing_entrypoint.tgz"

[[buildpacks]]
id = "google.utils.archive-source"
uri = "archive_source.tgz"

[[buildpacks]]
id = "google.utils.label-image"
uri = "label_image.tgz"
Expand All @@ -144,6 +148,10 @@ description = "Ubuntu 18 base image with buildpacks for .NET, Go, Java, Node.js,
id = "google.ruby.runtime"
uri = "ruby/runtime.tgz"

[[buildpacks]]
id = "google.ruby.functions-framework"
uri = "ruby/functions_framework.tgz"

[[buildpacks]]
id = "google.ruby.rubygems"
uri = "ruby/rubygems.tgz"
Expand Down Expand Up @@ -525,6 +533,7 @@ description = "Ubuntu 18 base image with buildpacks for .NET, Go, Java, Node.js,

[[order.group]]
id = "google.utils.label-image"


###########
# Ruby applications #
Expand Down Expand Up @@ -558,6 +567,26 @@ description = "Ubuntu 18 base image with buildpacks for .NET, Go, Java, Node.js,
[[order.group]]
id = "google.utils.label-image"

# The Ruby functions order group. Similar to the generic Ruby
# applications order group above but uses the GOOGLE_FUNCTION_TARGET
# env var to set the container entrypoint.
[[order]]
[[order.group]]
id = "google.ruby.runtime"

[[order.group]]
id = "google.utils.archive-source"
optional = true

[[order.group]]
id = "google.ruby.bundle"

[[order.group]]
id = "google.ruby.functions-framework"

[[order.group]]
id = "google.utils.label-image"

#######
# PHP #
#######
Expand Down
28 changes: 28 additions & 0 deletions builders/gcp/base/google.22.builder.toml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ description = "Ubuntu 22.04 base image with buildpacks for .NET, Dart, Go, Java,
id = "google.python.missing-entrypoint"
uri = "python/missing_entrypoint.tgz"

[[buildpacks]]
id = "google.utils.archive-source"
uri = "archive_source.tgz"

[[buildpacks]]
id = "google.utils.label-image"
uri = "label_image.tgz"
Expand All @@ -136,6 +140,10 @@ description = "Ubuntu 22.04 base image with buildpacks for .NET, Dart, Go, Java,
id = "google.ruby.runtime"
uri = "ruby/runtime.tgz"

[[buildpacks]]
id = "google.ruby.functions-framework"
uri = "ruby/functions_framework.tgz"

[[buildpacks]]
id = "google.ruby.rubygems"
uri = "ruby/rubygems.tgz"
Expand Down Expand Up @@ -550,6 +558,26 @@ description = "Ubuntu 22.04 base image with buildpacks for .NET, Dart, Go, Java,
[[order.group]]
id = "google.utils.label-image"

# The Ruby functions order group. Similar to the generic Ruby
# applications order group above but uses the GOOGLE_FUNCTION_TARGET
# env var to set the container entrypoint.
[[order]]
[[order.group]]
id = "google.ruby.runtime"

[[order.group]]
id = "google.utils.archive-source"
optional = true

[[order.group]]
id = "google.ruby.bundle"

[[order.group]]
id = "google.ruby.functions-framework"

[[order.group]]
id = "google.utils.label-image"

#######
# PHP #
#######
Expand Down
4 changes: 4 additions & 0 deletions tools/pull-images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,12 @@ readonly candidate="latest"

echo "Pulling stack images for ${product}/${runtime}"
if [[ "${product}" == "gcp" ]]; then
# We pull both the google-22 and the google-18 images, because the OSS builder
# supports both.
docker pull "gcr.io/buildpacks/${product}/run:${candidate}"
docker pull "gcr.io/buildpacks/${product}/build:${candidate}"
docker pull "gcr.io/buildpacks/google-22/build:${candidate}"
docker pull "gcr.io/buildpacks/google-22/run:{candidate}"
else
docker pull "gcr.io/${project}/buildpacks/${runtime}/run:${candidate}"
docker pull "gcr.io/${project}/buildpacks/${runtime}/build:${candidate}"
Expand Down

0 comments on commit 12d541e

Please sign in to comment.