Giter Site home page Giter Site logo

gofn's Introduction

gofn

Build Status GoDoc Go Report Card codecov

Function process via container provider

Premise

  • Software makes a task
  • After processing it dies
  • Must put on stdout (print) a string formatted as JSON

Install

go get github.com/nuveo/gofn

Example

package main

import (
	"flag"
	"fmt"
	"log"

	"github.com/nuveo/gofn"
	"github.com/nuveo/gofn/provision"
)

func main() {

	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")
	flag.Parse()

	stdout, err := gofn.Run(&provision.BuildOptions{
		ContextDir: *contextDir,
		Dockerfile: *dockerfile,
		ImageName:  *imageName,
		RemoteURI:  *remoteBuildURI,
	}, &provision.VolumeOptions{
		Source:	  *volumeSource,
		Destination: *volumeDestination,
	})
	if err != nil {
		log.Println(err)
	}

	fmt.Println(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 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

  • -h Shows the list of parameters

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

gofn's People

Contributors

cassiobotaro avatar crgimenes avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.