{"id":28528378,"url":"https://github.com/dokku/lambda-builder","last_synced_at":"2025-07-06T16:30:43.450Z","repository":{"id":38239035,"uuid":"482361211","full_name":"dokku/lambda-builder","owner":"dokku","description":"A tool for building lambda function images or zips via Docker","archived":false,"fork":false,"pushed_at":"2025-06-19T01:21:59.000Z","size":603,"stargazers_count":18,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-06-24T01:26:45.667Z","etag":null,"topics":["aws-lambda","deployment","docker","golang","lambda","packaging","serverless"],"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/dokku.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"dokku","open_collective":"dokku","patreon":"dokku"}},"created_at":"2022-04-16T21:05:47.000Z","updated_at":"2025-06-19T01:22:01.000Z","dependencies_parsed_at":"2023-12-19T07:20:46.851Z","dependency_job_id":"e5a8e82d-62a1-43d7-84d1-88135c1a4d13","html_url":"https://github.com/dokku/lambda-builder","commit_stats":{"total_commits":232,"total_committers":4,"mean_commits":58.0,"dds":0.375,"last_synced_commit":"a29bf5cb73e0b072735536f977f942bc56dd1800"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/dokku/lambda-builder","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dokku%2Flambda-builder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dokku%2Flambda-builder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dokku%2Flambda-builder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dokku%2Flambda-builder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dokku","download_url":"https://codeload.github.com/dokku/lambda-builder/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dokku%2Flambda-builder/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263223832,"owners_count":23433180,"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":["aws-lambda","deployment","docker","golang","lambda","packaging","serverless"],"created_at":"2025-06-09T12:41:25.230Z","updated_at":"2025-07-06T16:30:43.444Z","avatar_url":"https://github.com/dokku.png","language":"Go","funding_links":["https://github.com/sponsors/dokku","https://opencollective.com/dokku","https://patreon.com/dokku"],"categories":[],"sub_categories":[],"readme":"# lambda-builder\n\nA tool for building lamda functions into uploadable zip files via Docker based on work from [@lambci](https://github.com/lambci/docker-lambda) and [@mLupine](https://github.com/mLupine/docker-lambda).\n\n## Why?\n\nI don't want to go through the motions of figuring out the correct way to build my app for AWS. I suspect there are others out there who feel the same.\n\n## Dependencies\n\n- The `docker` binary\n- Golang 1.7+\n\n## Building\n\n```shell\n# substitute the version number as desired\ngo build -ldflags \"-X main.Version=0.5.0\"\n```\n\n## Usage\n\n```text\nUsage: lambda-builder [--version] [--help] \u003ccommand\u003e [\u003cargs\u003e]\n\nAvailable commands are:\n    build      Builds a lambda function\n    version    Return the version of the binary\n```\n\n### Building an app\n\nTo build an app:\n\n```shell\ncd path/to/app\n\n# will write a lambda.zip in the current working directory\nlambda-builder build\n```\n\nAlternatively, a given path can be specified via the `--working-directory` flag:\n\n```shell\n# will write a lambda.zip in the specified path\nlambda-builder build --working-directory path/to/app\n```\n\nCustom environment variables can be supplied for the build environment by specifying one or more `--build-env` flags. The `--build-env` flag takes `KEY=VALUE` pairs.\n\n```shell\n# the build step will have access to both the --build-env pairs\nlambda-builder build --build-env KEY=VALUE --build-env ANOTHER_KEY=some-value\n```\n\nA `builder` can be chosen by a flag. Note that while a `builder` may be selected, the detection for that builder must still pass in order for the build to succeed.\n\n```shell\nlambda-builder build --generate-image --builder dotnet\n```\n\n#### Building an image\n\nA docker image can be produced from the generated artifact by specifying the `--generate-image` flag. This also allows for multiple `--label` flags as well as specifying a single image tag via either `-t` or `--tag`:\n\n```shell\n# will write a lambda.zip in the specified path\n# and generate a docker image named `lambda-builder/$APP:latest`\n# where $APP is the last portion of the working directory\nlambda-builder build --generate-image\n\n# adds the labels com.example/key=value and com.example/another-key=value\nlambda-builder build --generate-image --label com.example/key=value --label com.example/another-key=value\n\n# tags the image as app/awesome:1234\nlambda-builder build --generate-image --tag app/awesome:1234\n```\n\nBy default, any web process started by the built image starts on port `9001`. This can be overriden via the `--port` environment variable.\n\n```shell\n# build the image and ensure it starts on port 5000 by default\nlambda-builder build --generate-image --port 5000\n```\n\nCustom environment variables can be supplied for the built image by specifying one or more `--image-env` flags. The `--image-env` flag takes `KEY=VALUE` pairs.\n\n```shell\n# the built image will have `ENV` directives corresponding to the values specified by `--image-env`\nlambda-builder build --generate-image --image-env KEY=VALUE --image-env ANOTHER_KEY=some-value\n```\n\nThe `build-image` and `run-image` can also be specified as flags:\n\n```shell\nlambda-builder build --generate-image --build-image \"mlupin/docker-lambda:dotnetcore3.1-build\" --run-image \"mlupin/docker-lambda:dotnetcore3.1\"\n```\n\nA generated image can be run locally with the following line:\n\n```shell\n# run the container and ensure it stays open\n# replace `$APP` with your folder name\ndocker run --rm -it -e DOCKER_LAMBDA_STAY_OPEN=1 -p 9001:9001 \"lambda-builder/$APP:latest\"\n\n# invoke it using the awscli (v2)\n# note that the function name in this example is `function.handler`\naws lambda invoke --endpoint http://localhost:9001 --no-sign-request --function-name function.handler --payload '{}' --cli-binary-format raw-in-base64-out output.json\n\n# invoke it via curl\ncurl -d '{}' http://localhost:9001/2015-03-31/functions/function.handler/invocations\n\n# the function can also be invoked directly from a container if desired\ndocker run --rm \"lambda-builder/$APP:latest\" function.handler '{\"name\": \"World\"}'\n```\n\n#### Generating a Procfile\n\nA `Procfile` can be written to the working directory by specifying the `--write-procfile` flag. This file will not be written if one already exists in the working directory. If an image is being built, the detected handler will also be injected into the build context and used as the default `CMD` for the image. The contents of the `Procfile` are a `web` process type and a detected handler.\n\n```shell\n# writes out a procfile\nlambda-builder build --write-procfile\n```\n\nA `--handler` flag can be specified with a custom handler to override the one detected.\n\n```shell\n# override with a custom handler\nlambda-builder build --write-procfile --handler foo_file.bar_func\n```\n\n### How does it work\n\nInternally, `lambda-builder` detects a given language and builds the app according to the script specified by the detected builder within a disposablecontainer environment emulating AWS Lambda. If a builder is not detected, the build will fail. The following languages are supported:\n\n- `dotnet`\n  - default build image: `mlupin/docker-lambda:dotnet6-build`\n  - requirement: `Function.cs`\n  - runtimes:\n    - dotnet6\n    - dotnetcore3.1\n- `go`\n  - default build image:\n    - With `go.mod`: `golang:1.22-bookworm`\n    - Without `go.mod`: `golang:1.17-buster`\n  - requirement: `go.mod` or `main.go`\n  - runtimes:\n    - provided.al2\n- `nodejs`\n  - default build image: `mlupin/docker-lambda:nodejs14.x-build`\n  - requirement: `package-lock.json`\n  - runtimes:\n    - nodejs12.x\n    - nodejs14.x\n- `python`\n  - default build image: `mlupin/docker-lambda:python3.9-build`\n  - requirement: `requirements.txt`, `poetry.lock`, or `Pipfile.lock`\n  - notes: Autodetects the python version from `poetry.lock`, `Pipfile.lock`, or `runtime.txt`\n  - runtimes:\n    - python3.8\n    - python3.9\n- `ruby`\n  - default build image: `mlupin/docker-lambda:ruby2.7-build`\n  - requirement: `Gemfile.lock`\n  - runtimes:\n    - ruby2.7\n\nAll builders support both pre (run before the app is compiled) and post (run after the app is compiled but before it is compressed into a `lambda.zip` file) compile hooks in the form of `bin/pre_compile` and `bin/post_compile`. These can be shell scripts or executables.\n\nWhen the app is built, a `lambda.zip` will be produced in the specified working directory. The resulting `lambda.zip` can be uploaded to S3 and used within a Lambda function.\n\nBoth the builder, build image environment, and the run image environment can be overriden in an optional `lambda.yml` file in the specified working directory.\n\n### `lambda.yml`\n\nThe following a short description of the `lambda.yml` format.\n\n```yaml\n---\nbuild_image: mlupin/docker-lambda:dotnetcore3.1-build\nbuilder: dotnet\nrun_image: mlupin/docker-lambda:dotnetcore3.1\n```\n\n- `build_image`: A docker image that is accessible by the docker daemon. The `build_image` _should_ be based on an existing Lambda image - builders may fail if they cannot run within the specified `build_image`. The build will fail if the image is inaccessible by the docker daemon.\n- `builder`: The name of a builder. This may be used if multiple builders match and a specific builder is desired. If an invalid builder is specified, the build will fail.\n- `run_image`: A docker image that is accessible by the docker daemon. The `run_image` _should_ be based on an existing Lambda image - built images may fail to start if they are not compatible with the produced artifact. The generation of the `run` iage will fail if the image is inaccessible by the docker daemon.\n\n### Deploying\n\nThe `lambda.zip` file can be directly uploaded to a lambda function and used as is by specifying the correct runtime. See the `test.bats` files in any of the `test` examples for more info on how to perform this with the `awscli` (v2).\n\n## Examples\n\nSee the `tests` directory for examples on how to use this project.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdokku%2Flambda-builder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdokku%2Flambda-builder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdokku%2Flambda-builder/lists"}