bazel run //builders/py37/stack:build
This command creates two images:
openfunctiondev/buildpacks-py37-run:v1
openfunctiondev/buildpacks-py37-build:v1
bazel build //builders/py37:builder.image
This command creates one image:
of/py37
Tag and push:
docker tag of/py37 <your container registry>/py37:v1
docker push <your container registry>/py37:v1
bazel test //builders/py37/acceptance/...
Output example:
INFO: Analyzed 2 targets (1 packages loaded, 5 targets configured).
INFO: Found 1 target and 1 test target...
INFO: Elapsed time: 31.606s, Critical Path: 31.33s
INFO: 2 processes: 1 internal, 1 local.
INFO: Build completed successfully, 2 total actions
//builders/py37/acceptance:python_fn_test PASSED in 31.3s
Executed 1 out of 1 test: 1 test passes.
INFO: Build completed successfully, 2 total actions
Download gcp samples:
git clone https://github.com/GoogleCloudPlatform/buildpack-samples.git
Build the function:
Add
--network host
to pack and docker command if they cannot reach internet.
cd buildpack-samples/sample-functions-framework-python/
pack build function-python --builder of/py37 --env FUNC_NAME="hello"
docker run --rm -p8080:8080 function-python
Visit the function:
curl http://localhost:8080
Output example:
hello, world
Definition of a Function
for python 3.7
is shown below:
apiVersion: core.openfunction.io/v1alpha1
kind: Function
metadata:
name: python-sample
spec:
version: "v1.0.0"
image: "<your registry name>/sample-python37-func:latest"
# port: 8080 # default to 8080
build:
builder: "openfunctiondev/py37-builder:v1"
params:
FUNC_NAME: "hello"
FUNC_TYPE: "http"
# FUNC_SRC: "main.py" # for python function
srcRepo:
url: "https://github.com/GoogleCloudPlatform/buildpack-samples.git"
sourceSubPath: "sample-functions-framework-python"
registry:
url: "https://index.docker.io/v1/"
account:
name: "basic-user-pass"
key: "username"
# serving:
# runtime: "Knative" # default to Knative