diff --git a/Dockerfile b/Dockerfile index 5119464..8ee59f5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,8 +4,11 @@ FROM public.ecr.aws/lambda/python:3.11 COPY requirements.txt /tmp/ RUN pip install --no-cache-dir -r /tmp/requirements.txt -t ${LAMBDA_TASK_ROOT} -# Copy the template_automation package -COPY template_automation/ ${LAMBDA_TASK_ROOT}/template_automation/ +# Copy all code files for package installation +COPY . /tmp/app/ + +# Install the package in development mode to make it available to Python +RUN pip install -e /tmp/app -t ${LAMBDA_TASK_ROOT} # Copy the root app.py file (this is essential for AWS Lambda to find the handler) COPY app.py ${LAMBDA_TASK_ROOT}/ diff --git a/packer.pkr.hcl b/packer.pkr.hcl index bb1b5f4..6492224 100644 --- a/packer.pkr.hcl +++ b/packer.pkr.hcl @@ -32,25 +32,19 @@ build { "source.docker.lambda" ] + # Copy the entire project directory for proper installation provisioner "file" { - source = "./template_automation/" - destination = "/var/task/template_automation/" - } - - provisioner "file" { - source = "./app.py" - destination = "/var/task/app.py" - } - - provisioner "file" { - source = "./requirements.txt" - destination = "/var/task/requirements.txt" + source = "./" + destination = "/tmp/" } provisioner "shell" { inline = [ - "ls -la /var/task", # Debug: List contents - "pip3 install -r /var/task/requirements.txt -t /var/task" + "ls -la /tmp", # Debug: List contents of tmp directory + "pip3 install -r /tmp/requirements.txt -t /var/task", + "pip3 install /tmp -t /var/task", # Install the package itself + "cp /tmp/app.py /var/task/", # Copy the entry point file + "ls -la /var/task" # Debug: List contents of task directory ] }