OpenFaaS Templates
golang-middleware-busybox
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
.
Overview
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.
Example
Please see the basic example below for how to structure your function within the repository.
Repository Structure
example
├── bin
│ └── ex-bin
└── handler.go
stack.yml
Golang Handler Snippet
example/handler.go
command := exec.Command("./bin/ex-bin")
Stack Configuration
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