{"id":16193516,"url":"https://github.com/pyramation/openfaas-docker-compose","last_synced_at":"2025-04-07T15:19:03.179Z","repository":{"id":66351083,"uuid":"292198099","full_name":"pyramation/openfaas-docker-compose","owner":"pyramation","description":null,"archived":false,"fork":false,"pushed_at":"2020-09-02T06:27:05.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-13T02:03:52.468Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pyramation.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-09-02T06:26:35.000Z","updated_at":"2020-09-02T06:27:08.000Z","dependencies_parsed_at":"2023-02-26T23:15:51.349Z","dependency_job_id":null,"html_url":"https://github.com/pyramation/openfaas-docker-compose","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/pyramation%2Fopenfaas-docker-compose","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyramation%2Fopenfaas-docker-compose/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyramation%2Fopenfaas-docker-compose/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyramation%2Fopenfaas-docker-compose/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pyramation","download_url":"https://codeload.github.com/pyramation/openfaas-docker-compose/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247675598,"owners_count":20977378,"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":[],"created_at":"2024-10-10T08:15:10.654Z","updated_at":"2025-04-07T15:19:03.162Z","avatar_url":"https://github.com/pyramation.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# openfaas-docker-compose\n\nExamples for running OpenFaaS in a development environment using\nDocker Compose.\n\nAll these are using officially supported templates, although these principles\nare used to demonstrate how to run OpenFaaS in a live-reload environment and\ncould be applied to any template.\n\nIf you are using the [Classic Watchdog](https://docs.openfaas.com/architecture/watchdog/#classic-watchdog),\nyou won't need to change the `fprocess` environment variable as the script isn't\ninvoked until the function is called.\n\n**IMPORTANT:** This does not give the full OpenFaaS suite of tools. It is\npurely to allow access to the function inside the container with live-reload\nsupport. You will still need to build the image.\n\n## Secrets\n\nOpenFaaS supports [secrets](https://docs.openfaas.com/reference/secrets/) by\nputting the file in `/var/openfaas/secrets`. Docker Compose stores secrets in\n`/run/secrets` so you will need to do some form of either/or load, appropriate\nto the language. I suggest putting the OpenFaaS version as the default to\nreduce load in the production environment.\n\n**IMPORTANT:** You should never store sensitive data in a repo.\n\nSee the `docker-compose.yaml` file and the `node12` function for an example\nas to how you can get this to work.\n\n## Running\n\n```shell script\nmake templates # This downloads the templates from the OpenFaaS template store\ndocker-compose up # This runs Docker Compose\n```\n\nThis may take a few moments to run the first time (eg, the NodeJS example\nhas to install `nodemon`). However, once running it will update changes very\nquickly indeed.\n\n## Invoking\n\nRunning in Docker Compose, we lose all the OpenFaaS support of password\nprotection, routing and the like - this is purely the function and nothing\nelse.\n\nTo invoke the function, you may use `curl`, [Postman](https://getpostman.com)\nor even your browser. Just make a call to the port - you can use `GET` or\n`POST` as you would in OpenFaaS.\n\n### NodeJS\n\nPort: 3000\n\n```shell script\ncurl -d '{ \"input\": \"data\" }' -H 'content-type: application/json' localhost:3000\n```\n\n### Python\n\nPort: 3001\n\n```shell script\ncurl -d '{\"input\": \"data\" }' -H 'content-type: application/json' localhost:3001\n```\n\n### Go\n\nPort: 3002\n\n```shell script\ncurl -d '{\"input\": \"data\" }' -H 'content-type: application/json' localhost:3002\n```\n\nThis one is a little more involved than NodeJS/Python because the Go template\nbuilds a binary and puts it into an empty Alpine container. We have to intercept\nthe build process to use the GoLang template by setting the `build.target` parameter\nto `build` (see [Docker Multi-Stage builds](https://docs.docker.com/develop/develop-images/multistage-build/)\nfor more information). As the OpenFaaS configuration is done in the final container,\nwe need to apply this configuration to the `build` target. This means setting the\n`mode` and `upstream_url` environment variables.\n\nFinally, this uses the Go package [Air](https://github.com/cosmtrek/air) to provide\nthe live reload facility. This requires a config file, even if there's nothing inside\nit. As we won't need this in production, there's a `.dockerignore` file to not send\nit to the image when building. However, the Docker Compose `volumes` ignores this,\nwhich is exactly what we need.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpyramation%2Fopenfaas-docker-compose","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpyramation%2Fopenfaas-docker-compose","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpyramation%2Fopenfaas-docker-compose/lists"}