openfaas / faas-cli

Official CLI for OpenFaaS
https://www.openfaas.com/
Other
798 stars 224 forks source link

Feature - buildpack support in faas-cli build #834

Closed alexellis closed 3 years ago

alexellis commented 4 years ago

Description

Feature - buildpack support in faas-cli build

Context

DigitalOcean's AppPlatform, Cloudrun, Heroku, Cloudfoundary, Waypoint all support buildpacks

build packs can generally be inferred automatically, and don't need a Dockerfile

An example for Golang would be the follow:

package main

import (
    "log"
    "net/http"
    "os"
)

func main() {

    port := "8080"
    if val, _ := os.LookupEnv("PORT"); len(val) > 0 {
        port = val
    }

    http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
        w.Write([]byte("Invoked"))
    })
    http.HandleFunc("/_/healthz", func(w http.ResponseWriter, r *http.Request) {
        w.Write([]byte("OK"))
    })

    log.Printf("listening on %s\n", port)
    err := http.ListenAndServe(":"+port, nil)
    if err != nil {
        panic(err)
    }
}

An example of building this would be:

pack build go-mod --builder gcr.io/buildpacks/builder:v1

We could generate this command like we do for faas-cli build. The push and deploy commands would stay the same.

The format for specifying a build pack could be the following where the lang is a buildpack builder i.e. gcr.io/buildpacks/builder:v1 - the / is how we can determine to run pack build instead of docker build

version: 1.0
provider:
  name: openfaas
  gateway: http://127.0.0.1:8080
functions:
  go-mod-app:
    lang: gcr.io/buildpacks/builder:v1
    handler: ./go-mod-app
    image: go-mod-app:latest

I don't see much for us to lose by trying this out as an experiment, if it doesn't get traction, and becomes a burden then it can be removed.

alexellis commented 4 years ago

@yankeexe can you please ask upstream about an ARM release binary on "pack"? cc https://github.com/alexellis/arkade/pull/231

yankeexe commented 4 years ago

@alexellis Link to issue: https://github.com/buildpacks/pack/issues/907

alexellis commented 3 years ago

Closing due to lack of interest from community.