{"id":13773401,"url":"https://github.com/gofn/gofn","last_synced_at":"2025-05-11T05:34:39.465Z","repository":{"id":57496071,"uuid":"75209399","full_name":"gofn/gofn","owner":"gofn","description":"Function process via docker provider (serverless minimalist)","archived":true,"fork":false,"pushed_at":"2018-12-11T16:14:46.000Z","size":3761,"stargazers_count":138,"open_issues_count":24,"forks_count":13,"subscribers_count":14,"default_branch":"master","last_synced_at":"2024-11-17T08:44:23.570Z","etag":null,"topics":["docker","faas","functions","functions-as-a-service","lambda","prometheus","serverless","service","swarm"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gofn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-11-30T17:14:40.000Z","updated_at":"2024-04-21T12:37:21.000Z","dependencies_parsed_at":"2022-09-16T09:40:16.769Z","dependency_job_id":null,"html_url":"https://github.com/gofn/gofn","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gofn%2Fgofn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gofn%2Fgofn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gofn%2Fgofn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gofn%2Fgofn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gofn","download_url":"https://codeload.github.com/gofn/gofn/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253523689,"owners_count":21921815,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","faas","functions","functions-as-a-service","lambda","prometheus","serverless","service","swarm"],"created_at":"2024-08-03T17:01:15.186Z","updated_at":"2025-05-11T05:34:34.450Z","avatar_url":"https://github.com/gofn.png","language":"Go","funding_links":[],"categories":["Uncategorized"],"sub_categories":["Uncategorized"],"readme":"![gofn](docs/assets/logo.png)\n\n[![Build Status](https://travis-ci.org/gofn/gofn.svg?branch=master)](https://travis-ci.org/gofn/gofn)\n[![GoDoc](https://godoc.org/github.com/gofn/gofn?status.png)](https://godoc.org/github.com/gofn/gofn)\n[![Go Report Card](https://goreportcard.com/badge/github.com/gofn/gofn)](https://goreportcard.com/report/github.com/gofn/gofn)\n[![codecov](https://codecov.io/gh/gofn/gofn/branch/master/graph/badge.svg)](https://codecov.io/gh/gofn/gofn)\n[![Join the chat at https://gitter.im/gofn/gofn](https://badges.gitter.im/gofn/gofn.svg)](https://gitter.im/gofn/gofn?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n[![Open Source Helpers](https://www.codetriage.com/nuveo/gofn/badges/users.svg)](https://www.codetriage.com/nuveo/gofn)\n\nFunction process via docker provider\n\n## Install\n\n```bash\ngo get github.com/gofn/gofn\n```\n\n## Example\n\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"flag\"\n\t\"fmt\"\n\t\"log\"\n\t\"os\"\n\t\"runtime\"\n\t\"sync\"\n\n\t\"github.com/gofn/gofn\"\n\t\"github.com/gofn/gofn/iaas/digitalocean\"\n\t\"github.com/gofn/gofn/provision\"\n)\n\nfunc main() {\n\twait := \u0026sync.WaitGroup{}\n\tcontextDir := flag.String(\"contextDir\", \"./\", \"a string\")\n\tdockerfile := flag.String(\"dockerfile\", \"Dockerfile\", \"a string\")\n\timageName := flag.String(\"imageName\", \"\", \"a string\")\n\tremoteBuildURI := flag.String(\"remoteBuildURI\", \"\", \"a string\")\n\tvolumeSource := flag.String(\"volumeSource\", \"\", \"a string\")\n\tvolumeDestination := flag.String(\"volumeDestination\", \"\", \"a string\")\n\tremoteBuild := flag.Bool(\"remoteBuild\", false, \"true or false\")\n\tinput := flag.String(\"input\", \"\", \"a string\")\n\tflag.Parse()\n\tparallels := runtime.GOMAXPROCS(-1) // use max allowed CPUs to parallelize\n\twait.Add(parallels)\n\tfor i := 0; i \u003c parallels; i++ {\n\t\tgo run(*contextDir, *dockerfile, *imageName, *remoteBuildURI, *volumeSource, *volumeDestination, wait, *remoteBuild, *input)\n\t}\n\twait.Wait()\n}\n\nfunc run(contextDir, dockerfile, imageName, remoteBuildURI, volumeSource, volumeDestination string, wait *sync.WaitGroup, remote bool, input string) {\n\tbuildOpts := \u0026provision.BuildOptions{\n\t\tContextDir: contextDir,\n\t\tDockerfile: dockerfile,\n\t\tImageName:  imageName,\n\t\tRemoteURI:  remoteBuildURI,\n\t\tStdIN:      input,\n\t}\n\tcontainerOpts := \u0026provision.ContainerOptions{}\n\tif volumeSource != \"\" {\n\t\tif volumeDestination == \"\" {\n\t\t\tvolumeDestination = volumeSource\n\t\t}\n\t\tcontainerOpts.Volumes = []string{fmt.Sprintf(\"%s:%s\", volumeSource, volumeDestination)}\n\t}\n\tif remote {\n\t\tkey := os.Getenv(\"DIGITALOCEAN_API_KEY\")\n\t\tif key == \"\" {\n\t\t\tlog.Fatalln(\"You must provide an api key for digital ocean\")\n\t\t}\n\t\tdo, err := digitalocean.New(key)\n\t\tif err != nil {\n\t\t\tlog.Println(err)\n\t\t}\n\t\tbuildOpts.Iaas = do\n\t}\n\n\tdefer wait.Done()\n\tstdout, stderr, err := gofn.Run(context.Background(), buildOpts, containerOpts)\n\tif err != nil {\n\t\tlog.Println(err)\n\t}\n\tfmt.Println(\"Stderr: \", stderr)\n\tfmt.Println(\"Stdout: \", stdout)\n}\n```\n\n### Run Example\n\n```bash\ncd examples\n\ngo run main.go -contextDir=testDocker -imageName=python -dockerfile=Dockerfile\n\n# or using volume\ngo run main.go -contextDir=testDocker -imageName=python -dockerfile=Dockerfile -volumeSource=/tmp -volumeDestination=/tmp\n\n# or using remote Dockerfile\ngo run main.go -remoteBuildURI=https://github.com/gofn/dockerfile-python-example.git -imageName=\"pythonexample\"\n\n# you can also send a string that will be written to the stdin of the container\ngo run main.go -contextDir=testDocker -imageName=python -dockerfile=Dockerfile -input \"input string\"\n\n# or run in digital ocean\nexport DIGITALOCEAN_API_KEY=\"paste your key here\"\ngo run main.go -contextDir=testDocker -imageName=python -dockerfile=Dockerfile -remoteBuild=true\n```\n\nYou can also compile with _go build_ or build and install with _go install_ command then run it as a native executable.\n\n### Example Parameters\n\n* -contextDir is the root directory where the Dockerfile, scripts, and other container dependencies are, by default current directory \"./\".\n\n* -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.\n\n* -dockerFile is the name of the file containing the container settings, by default Dockerfile\n\n* -volumeSource is the directory that will be mounted as a data volume. By default is empty string indicating his not used.\n\n* -volumeDestination is the path mounted inside the container. By default is empty string indicating his not used but if only omitted, volumeSource is used.\n\n* -remoteBuildURI is remote URI containing the Dockerfile to build.By default is empty.\n  More details on [docker api docs](https://docs.docker.com/engine/reference/commandline/build/#/git-repositories)\n\n* remoteBuild is a boolean that indicates if have to run localally or in a machine in digital ocean\n  Don't forget to export your api key.\n\n* -input is a string that will be written to the stdin of the container\n\n* -h Shows the list of parameters\n\ngofn generates the images with \"gofn/\" as a prefix.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgofn%2Fgofn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgofn%2Fgofn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgofn%2Fgofn/lists"}