Skip to content

Commit

Permalink
Refactor Dockerfile and Packer configuration: streamline file copying…
Browse files Browse the repository at this point in the history
… and installation process
  • Loading branch information
Your Name committed May 7, 2025
1 parent c650e56 commit 279030a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
7 changes: 5 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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}/
Expand Down
22 changes: 8 additions & 14 deletions packer.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -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
]
}

Expand Down

0 comments on commit 279030a

Please sign in to comment.