micmurawski / poetry-plugin-lambda-build

Poetry plugin for building packages for serverless functions deployments like AWS Lambda, Google App Engine, Azure App Service, and more...
MIT License
38 stars 5 forks source link

separate lambda, layer packages w/ docker build issue #34

Open vishnurpiper opened 3 weeks ago

vishnurpiper commented 3 weeks ago

This is my project setup (using standard poetry folder structures) -

src
|____poetry-package-one (lambda function)
|_______poetry-package-one
|_________index.py
|_______pyproject.toml
|____poetry-package-two (lambda function)
|_______poetry-package-two
|_________index.py
|_______pyproject.toml
|____poetry-lib-package (local package with reusable functions used in lambda functions)
|_______poetry-lib-package
|_________util.py
|_______pyproject.toml

each of the lambda packages reference the local lib package (something like below - works fine for local development & debugging)

[tool.poetry.dependencies]
python = "^3.11"
poetry-lib-package = {path = "../poetry-lib-package", develop = true}

Ran the plugin from one of the lambda package folders using poetry build-lambda Works great (all in one or separate lambda/layer packages) w/o docker build. The zips created have all the dependencies (including the local package)

When I add docker build, there's an error that its unable to find the local poetry-lib-package. Most likely when in the context of the docker container, it does not have the lib package in src. Path poetry-lib-package does not exist The zips produced are empty when this error occurs.

[tool.poetry-plugin-lambda-build]
layer-artifact-path = "artifacts/layer.zip"
layer-install-dir = "python"
function-artifact-path = "artifacts/function.zip"
docker-image = "base-python-for-lambda"
docker-network = "host"

Does my setup look ok?

micmurawski commented 3 weeks ago

@vishnurpiper

Your configuration is fine. This is the limitation of the plugin unfortunately I did not foresee. It's caused by my simplistic use of the copy_to_container function

            copy_to_container(src=f"{CURRENT_WORK_DIR}/.", dst=f"{container.id}:/")

Thanks for finding this limitation. I will be able to fix that next week unless you would like to make some contribution.

vishnurpiper commented 3 weeks ago

Thanks for the quick response. I'll take a look, don't think I'll beat you to a fix considering commitments on my end. But, do keep me posted when you have something for me to try. Just an hour into using the plugin, it has been a big time saver so far.