diff --git a/functions/knative/hello-world-python/Dockerfile b/functions/knative/hello-world-python/Dockerfile new file mode 100644 index 0000000..58032c8 --- /dev/null +++ b/functions/knative/hello-world-python/Dockerfile @@ -0,0 +1,17 @@ +# New gcp-builder builder for MacOS m2 chip +FROM openfunction/gcp-builder:v1 + +# Unzip package lifecycle-v0.13.2+linux.arm64.tgz and download it from https://github.com/buildpacks/lifecycle/releases?q=0.13.2&expanded=true +COPY ./lifecycle /cnb/lifecycle + +# Upgrade lifycycle image version to 0.13.2 +LABEL io.buildpacks.builder.metadata="{\"description\":\"Ubuntu 18 base image with buildpacks for .NET, Go, Java, Node.js, and Python\",\"buildpacks\":[{\"id\":\"google.config.entrypoint\",\"name\":\"Config - Entrypoint\",\"version\":\"0.9.0\"},{\"id\":\"google.cpp.clear_source\",\"name\":\"C++ - Clear Source\",\"version\":\"0.1.0\"},{\"id\":\"google.cpp.functions-framework\",\"name\":\"C++ - Functions Framework\",\"version\":\"0.1.0\"},{\"id\":\"google.go.clear_source\",\"name\":\"Go - Clear Source\",\"version\":\"0.9.0\"},{\"id\":\"google.dotnet.runtime\",\"name\":\".NET - Runtime\",\"version\":\"0.9.1\"},{\"id\":\"google.dotnet.publish\",\"name\":\".NET - Publish\",\"version\":\"0.9.0\"},{\"id\":\"google.dotnet.functions-framework\",\"name\":\".NET - Functions Framework\",\"version\":\"0.0.1\"},{\"id\":\"google.go.runtime\",\"name\":\"Go - Runtime\",\"version\":\"0.9.1\"},{\"id\":\"google.go.build\",\"name\":\"Go - Build\",\"version\":\"0.9.0\"},{\"id\":\"google.go.gopath\",\"name\":\"Go - Gopath\",\"version\":\"0.9.0\"},{\"id\":\"google.go.functions-framework\",\"name\":\"Go - Functions Framework\",\"version\":\"0.9.4\"},{\"id\":\"google.java.entrypoint\",\"name\":\"Java - Entrypoint\",\"version\":\"0.9.0\"},{\"id\":\"google.java.exploded-jar\",\"name\":\"Java - Exploded Jar\",\"version\":\"0.9.0\"},{\"id\":\"google.java.functions-framework\",\"name\":\"Java - Functions Framework Invoker\",\"version\":\"1.0.1\"},{\"id\":\"google.java.gradle\",\"name\":\"Java - Gradle\",\"version\":\"0.9.0\"},{\"id\":\"google.java.maven\",\"name\":\"Java - Maven\",\"version\":\"0.9.0\"},{\"id\":\"google.java.runtime\",\"name\":\"Java - Runtime\",\"version\":\"0.9.1\"},{\"id\":\"google.java.clear_source\",\"name\":\"Java - Clear Source\",\"version\":\"0.9.0\"},{\"id\":\"google.nodejs.runtime\",\"name\":\"Node.js - Runtime\",\"version\":\"0.9.2\"},{\"id\":\"google.nodejs.npm\",\"name\":\"Node.js - NPM\",\"version\":\"0.9.0\"},{\"id\":\"google.nodejs.yarn\",\"name\":\"Node.js - Yarn\",\"version\":\"0.9.0\"},{\"id\":\"google.nodejs.functions-framework\",\"name\":\"Node.js - Functions Framework\",\"version\":\"0.9.1\"},{\"id\":\"google.python.runtime\",\"name\":\"Python - Runtime\",\"version\":\"0.9.1\"},{\"id\":\"google.python.pip\",\"name\":\"Python - pip\",\"version\":\"0.9.2\"},{\"id\":\"google.python.functions-framework\",\"name\":\"Python - Functions Framework\",\"version\":\"0.9.4\"},{\"id\":\"google.python.missing-entrypoint\",\"name\":\"Python - pip\",\"version\":\"0.9.0\"},{\"id\":\"google.utils.label\",\"name\":\"Utils - Label Image\",\"version\":\"0.0.1\"}],\"stack\":{\"runImage\":{\"image\":\"openfunction/buildpacks-gcp-run:v1\",\"mirrors\":null}},\"lifecycle\":{\"version\":\"0.13.2\",\"api\":{\"buildpack\":\"0.2\",\"platform\":\"0.3\"},\"apis\":{\"buildpack\":{\"deprecated\":[],\"supported\":[\"0.2\",\"0.3\",\"0.4\",\"0.5\",\"0.6\",\"0.7\",\"0.8\",\"0.9\",\"0.10\"]},\"platform\":{\"deprecated\":[],\"supported\":[\"0.3\",\"0.4\",\"0.5\",\"0.6\",\"0.7\",\"0.8\",\"0.9\",\"0.10\",\"0.11\",\"0.12\"]}}},\"createdBy\":{\"name\":\"Pack CLI\",\"version\":\"0.18.1+git-b5c1a96.build-2373\"}}" + +# build +# docker build -t /openfunction-gcp-builder:v1 . + +# push image +# docker push /openfunction-gcp-builder:v1 + +# run build pack +# pack build python-sample --builder /openfunction-gcp-builder:v1 --env GOOGLE_FUNCTION_TARGET=hello_world --verbose \ No newline at end of file diff --git a/functions/knative/hello-world-python/README.md b/functions/knative/hello-world-python/README.md index e39e3f7..28c38ba 100644 --- a/functions/knative/hello-world-python/README.md +++ b/functions/knative/hello-world-python/README.md @@ -13,6 +13,15 @@ Build the function locally pack build python-sample --builder openfunction/gcp-builder:v1 --env GOOGLE_FUNCTION_TARGET=hello_world ``` +The builder image used above may not be suitable for the MacOS m2 chip (Arm) architecture. For solutions, please refer to [Dockerfile](./Dockerfile) and then you can use the newly built builder image like: +```sh +pack build python-sample --builder /openfunction-gcp-builder:v1 --env GOOGLE_FUNCTION_TARGET=hello_world +``` +If it is just for research use, you can also use the image created by @ToviHe `hetovi1997/openfunction-gcp-builder:v1` + + + + Run the function ```sh