All Projects → gofn → Gofn

gofn / Gofn

Licence: mit
Function process via docker provider (serverless minimalist)

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to Gofn

Faas
OpenFaaS - Serverless Functions Made Simple
Stars: ✭ 20,820 (+15437.31%)
Mutual labels:  serverless, lambda, faas, functions, functions-as-a-service, prometheus
Fission
Fast and Simple Serverless Functions for Kubernetes
Stars: ✭ 6,646 (+4859.7%)
Mutual labels:  serverless, faas, lambda, functions, functions-as-a-service
Openwhisk
Apache OpenWhisk is an open source serverless cloud platform
Stars: ✭ 5,499 (+4003.73%)
Mutual labels:  serverless, faas, functions, functions-as-a-service
Fn
The container native, cloud agnostic serverless platform.
Stars: ✭ 5,046 (+3665.67%)
Mutual labels:  serverless, lambda, faas, swarm
Openwhisk Runtime Nodejs
Apache OpenWhisk Runtime NodeJS supports Apache OpenWhisk functions written in JavaScript for NodeJS
Stars: ✭ 43 (-67.91%)
Mutual labels:  serverless, faas, functions, functions-as-a-service
Openwhisk Runtime Php
Apache OpenWhisk Runtime PHP supports Apache OpenWhisk functions written in PHP
Stars: ✭ 26 (-80.6%)
Mutual labels:  serverless, faas, functions, functions-as-a-service
Openwhisk Devtools
Development tools for building and deploying Apache OpenWhisk
Stars: ✭ 141 (+5.22%)
Mutual labels:  serverless, faas, functions, functions-as-a-service
Flogo
Project Flogo is an open source ecosystem of opinionated event-driven capabilities to simplify building efficient & modern serverless functions, microservices & edge apps.
Stars: ✭ 1,891 (+1311.19%)
Mutual labels:  serverless, lambda, faas, functions-as-a-service
Openwhisk Deploy Kube
The Apache OpenWhisk Kubernetes Deployment repository supports deploying the Apache OpenWhisk system on Kubernetes and OpenShift clusters.
Stars: ✭ 231 (+72.39%)
Mutual labels:  serverless, faas, functions, functions-as-a-service
Openwhisk Cli
Apache OpenWhisk Command Line Interface (CLI)
Stars: ✭ 73 (-45.52%)
Mutual labels:  serverless, faas, functions, functions-as-a-service
Functional Typescript
TypeScript standard for rock solid serverless functions.
Stars: ✭ 600 (+347.76%)
Mutual labels:  serverless, lambda, faas
Microcule
SDK and CLI for spawning streaming stateless HTTP microservices in multiple programming languages
Stars: ✭ 454 (+238.81%)
Mutual labels:  serverless, faas, functions
Kotless
Kotlin Serverless Framework
Stars: ✭ 721 (+438.06%)
Mutual labels:  serverless, lambda, faas
Dispatch
Dispatch is a framework for deploying and managing serverless style applications.
Stars: ✭ 529 (+294.78%)
Mutual labels:  serverless, faas, functions
Nuclio
High-Performance Serverless event and data processing platform
Stars: ✭ 4,213 (+3044.03%)
Mutual labels:  serverless, faas, functions
Lambdalogs
A CLI tool to trace AWS Lambda calls over multiple CloudWatch log groups.
Stars: ✭ 18 (-86.57%)
Mutual labels:  serverless, lambda, faas
Mongodb Function
OpenFaaS Function that makes use of a connection pool to access MongoDB
Stars: ✭ 44 (-67.16%)
Mutual labels:  serverless, faas, functions
Composer
Composer is a new programming model for composing cloud functions built on Apache OpenWhisk.
Stars: ✭ 131 (-2.24%)
Mutual labels:  serverless, faas, functions
Apex
Old apex/apex
Stars: ✭ 20 (-85.07%)
Mutual labels:  serverless, lambda, faas
Graphql Serverless
GraphQL (incl. a GraphiQL interface) middleware for the webfunc serverless web framework.
Stars: ✭ 124 (-7.46%)
Mutual labels:  serverless, faas, functions

gofn

Build Status GoDoc Go Report Card codecov Join the chat at https://gitter.im/gofn/gofn Open Source Helpers

Function process via docker provider

Install

go get github.com/gofn/gofn

Example

package main

import (
	"context"
	"flag"
	"fmt"
	"log"
	"os"
	"runtime"
	"sync"

	"github.com/gofn/gofn"
	"github.com/gofn/gofn/iaas/digitalocean"
	"github.com/gofn/gofn/provision"
)

func main() {
	wait := &sync.WaitGroup{}
	contextDir := flag.String("contextDir", "./", "a string")
	dockerfile := flag.String("dockerfile", "Dockerfile", "a string")
	imageName := flag.String("imageName", "", "a string")
	remoteBuildURI := flag.String("remoteBuildURI", "", "a string")
	volumeSource := flag.String("volumeSource", "", "a string")
	volumeDestination := flag.String("volumeDestination", "", "a string")
	remoteBuild := flag.Bool("remoteBuild", false, "true or false")
	input := flag.String("input", "", "a string")
	flag.Parse()
	parallels := runtime.GOMAXPROCS(-1) // use max allowed CPUs to parallelize
	wait.Add(parallels)
	for i := 0; i < parallels; i++ {
		go run(*contextDir, *dockerfile, *imageName, *remoteBuildURI, *volumeSource, *volumeDestination, wait, *remoteBuild, *input)
	}
	wait.Wait()
}

func run(contextDir, dockerfile, imageName, remoteBuildURI, volumeSource, volumeDestination string, wait *sync.WaitGroup, remote bool, input string) {
	buildOpts := &provision.BuildOptions{
		ContextDir: contextDir,
		Dockerfile: dockerfile,
		ImageName:  imageName,
		RemoteURI:  remoteBuildURI,
		StdIN:      input,
	}
	containerOpts := &provision.ContainerOptions{}
	if volumeSource != "" {
		if volumeDestination == "" {
			volumeDestination = volumeSource
		}
		containerOpts.Volumes = []string{fmt.Sprintf("%s:%s", volumeSource, volumeDestination)}
	}
	if remote {
		key := os.Getenv("DIGITALOCEAN_API_KEY")
		if key == "" {
			log.Fatalln("You must provide an api key for digital ocean")
		}
		do, err := digitalocean.New(key)
		if err != nil {
			log.Println(err)
		}
		buildOpts.Iaas = do
	}

	defer wait.Done()
	stdout, stderr, err := gofn.Run(context.Background(), buildOpts, containerOpts)
	if err != nil {
		log.Println(err)
	}
	fmt.Println("Stderr: ", stderr)
	fmt.Println("Stdout: ", stdout)
}

Run Example

cd examples

go run main.go -contextDir=testDocker -imageName=python -dockerfile=Dockerfile

# or using volume
go run main.go -contextDir=testDocker -imageName=python -dockerfile=Dockerfile -volumeSource=/tmp -volumeDestination=/tmp

# or using remote Dockerfile
go run main.go -remoteBuildURI=https://github.com/gofn/dockerfile-python-example.git -imageName="pythonexample"

# you can also send a string that will be written to the stdin of the container
go run main.go -contextDir=testDocker -imageName=python -dockerfile=Dockerfile -input "input string"

# or run in digital ocean
export DIGITALOCEAN_API_KEY="paste your key here"
go run main.go -contextDir=testDocker -imageName=python -dockerfile=Dockerfile -remoteBuild=true

You can also compile with go build or build and install with go install command then run it as a native executable.

Example Parameters

  • -contextDir is the root directory where the Dockerfile, scripts, and other container dependencies are, by default current directory "./".

  • -imageName is the name of the image you want to start, if it does not exist it will be automatically generated and if it exists the system will just start the container.

  • -dockerFile is the name of the file containing the container settings, by default Dockerfile

  • -volumeSource is the directory that will be mounted as a data volume. By default is empty string indicating his not used.

  • -volumeDestination is the path mounted inside the container. By default is empty string indicating his not used but if only omitted, volumeSource is used.

  • -remoteBuildURI is remote URI containing the Dockerfile to build.By default is empty. More details on docker api docs

  • remoteBuild is a boolean that indicates if have to run localally or in a machine in digital ocean Don't forget to export your api key.

  • -input is a string that will be written to the stdin of the container

  • -h Shows the list of parameters

gofn generates the images with "gofn/" as a prefix.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].