This template is mostly the same as golang-middleware with the following differences:
- The final image is
busybox:1.3.2-glibc
instead ofalpine
- Any binaries in the
bin
directory relative to the function will be added to thebin
directory inside the working directory of the function, relative tobin
and be given executable permissions:chmod +x
.
The purpose of using busybox:glibc
as the base image is to account for some of the
deficiencies in alpine
when it comes to DNS resolution.
The copied in binaries from the bin
directory allow users to use
golang
exec to call the executables from the function handler.
Please see the basic example below for how to structure your function within the repository.
example
├── bin
│ └── ex-bin
└── handler.go
stack.yml
example/handler.go
command := exec.Command("./bin/ex-bin")
stack.yml
version: 1.0
provider:
name: openfaas
gateway: http://127.0.0.1:8080
functions:
example:
lang: golang-middleware-busybox
handler: ./example
image: example:latest