Closed mdesoeuv closed 1 month ago
same here
I solve it! @mdesoeuv
Based on code that module, create temp directory under /var/... and mount it. So, colima can't mount that directory.
Here is several options to solve this problem.
colima template
# Configure volume mounts for the virtual machine.
# Colima mounts user's home directory by default to provide a familiar
# user experience.
#
# EXAMPLE
# mounts:
# - location: ~/secrets
# writable: false
# - location: ~/projects
# writable: true
#
# Colima default behaviour: $HOME and /tmp/colima are mounted as writable.
# Default: []
mounts: []
source_path = [
"${path.module}/src",
{
path = "${path.module}/requirements.txt"
pip_requirements = true
pip_tmp_dir = "${path.module}/.temp"
}
]
Thank you for responding to this post with your fix, your help is appreciated
This issue has been automatically marked as stale because it has been open 30 days with no activity. Remove stale label or comment or this issue will be closed in 10 days
This issue was automatically closed because of stale in 10 days
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Description
The build of a Poetry Project in docker with the lambda module fails. It seems related to a permissions problem with the temporary folder created and bound to the container during the build process.
Versions
Reproduction Code [Required]
Steps to reproduce the behavior:
terraform init
terraform apply
Project Structure
``` . ├── builds │ └── lambda ├── lambda │ ├── README.md │ ├── docker │ │ └── Dockerfile │ ├── poetry.lock │ ├── pyproject.toml │ ├── src │ │ └── api │ │ ├── __init__.py │ │ └── main.py │ └── tests │ └── __init__.py ├── main.tf ```Terraform
``` module "lambda_backend" { source = "terraform-aws-modules/lambda/aws" function_name = "api-lambda" description = "FastAPI in AWS Lambda" handler = "api.main.handler" publish = true create_lambda_function_url = true source_path = [ "${path.module}/lambda/src", { path = "${path.module}/lambda/pyproject.toml" poetry_install = true } ] artifacts_dir = "${path.root}/builds/lambda/" build_in_docker = true runtime = "python3.10" docker_image = "build-python3.10-poetry" docker_file = "${path.module}/lambda/docker/Dockerfile" cloudwatch_logs_retention_in_days = 3 } output "lambda_url" { value = module.lambda_backend.lambda_function_url } ```Lambda Source Code
```python from fastapi import FastAPI from mangum import Mangum app = FastAPI() handler = Mangum(app, lifespan="off") @app.get("/") def root(): return {"Hello World !"} ```pyproject.toml
``` [tool.poetry] name = "api" version = "0.1.0" description = "" authors = ["mdesoeuvreDockerfile
```Dockerfile FROM public.ecr.aws/sam/build-python3.10:latest RUN pip install poetry==1.7.1 ```Expected behavior
The build should succeed as it does with Docker Desktop
Actual behavior
The build fails with the error:
Poetry could not find a pyproject.toml file in /var/task or its parents
Additional context
ls command inside the container with an other folder mounted in the container : OK
``` ❯ docker run --rm -w /var/task -v ~/Downloads/FastApi/lambda:/var/task:z -v /Users/mdesoeuvre/.ssh/known_hosts:/root/.ssh/known_hosts:z --entrypoint '' fdbb6bb2ed34 /bin/sh -c 'ls -la /var/task' total 100 drwxr-xr-x 1 503 games 288 Feb 20 15:40 . drwxr-xr-x 1 root root 4096 Feb 6 19:58 .. drwxr-xr-x 1 503 games 96 Feb 20 15:33 docker -rw-r--r-- 1 503 games 65930 Feb 20 15:27 poetry.lock -rw-r--r-- 1 503 games 448 Feb 20 15:27 pyproject.toml -rw-r--r-- 1 503 games 0 Feb 20 15:22 README.md drwxr-xr-x 1 503 games 96 Feb 20 15:26 src drwxr-xr-x 1 503 games 96 Feb 20 15:22 tests -rw-r--r-- 1 503 games 15 Feb 20 15:25 .tool-versions ```ls command inside the container with temp folder : fail
``` ❯ mktemp -d "$TMPDIR/terraform-aws-lambda-XXXXXXXX" /var/folders/tt/zl9rh1j93pz1b_05kfm1p9lr0000gq/T//terraform-aws-lambda-eq7lvce5 ❯ cp -r ./* /var/folders/tt/zl9rh1j93pz1b_05kfm1p9lr0000gq/T//terraform-aws-lambda-eq7lvce5 ❯ docker run --rm -w /var/task -v /var/folders/tt/zl9rh1j93pz1b_05kfm1p9lr0000gq/T/terraform-aws-lambda-eq7lvce5:/var/task:z -v /Users/mdesoeuvre/.ssh/known_hosts:/root/.ssh/known_hosts:z --entrypoint '' fdbb6bb2ed34 /bin/sh -c 'ls -la /var/task' total 12 drwxr-xr-x 2 root root 4096 Feb 20 16:11 . drwxr-xr-x 1 root root 4096 Feb 6 19:58 .. ```#524
because the build works fine with Docker Desktop but fails with Rancher Desktop or docker cli