Skip to content

Commit 09b43ec

Browse files
Enhance Dockerfile for AWS Lambda deployment by adding system dependencies, setting up the working directory, and optimizing the installation of Python packages. Create necessary directories for certificate storage and configure environment variables for improved application performance.
1 parent a31a230 commit 09b43ec

2 files changed

Lines changed: 31 additions & 7 deletions

File tree

Dockerfile

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,36 @@
11
FROM public.ecr.aws/lambda/python:3.13
22

3-
ENV PYTHONDONTWRITEBYTECODE=1
4-
ENV PYTHONUNBUFFERED=1
3+
# Install system dependencies
4+
RUN dnf update -y && \
5+
dnf install -y \
6+
freetype-devel \
7+
libjpeg-turbo-devel \
8+
zlib-devel \
9+
gcc \
10+
make \
11+
python3-devel \
12+
fontconfig && \
13+
dnf clean all
14+
15+
# Set working directory
16+
WORKDIR ${LAMBDA_TASK_ROOT}
17+
18+
# Copy requirements first to leverage Docker cache
19+
COPY requirements.txt .
20+
RUN pip install --no-cache-dir -r requirements.txt
521

6-
WORKDIR /var/task
22+
# Copy the entire application
723
COPY . .
824

9-
RUN python -m pip install -r requirements.txt
25+
# Create necessary directories
26+
RUN mkdir -p /tmp/certificates && \
27+
chmod 777 /tmp/certificates
28+
29+
# Set environment variables
30+
ENV PYTHONPATH=${LAMBDA_TASK_ROOT}
31+
ENV FONTCONFIG_PATH=/etc/fonts
32+
ENV PYTHONDONTWRITEBYTECODE=1
33+
ENV PYTHONUNBUFFERED=1
1034

11-
EXPOSE 9000
12-
CMD ["lambda_function.lambda_handler"]
35+
# Set the CMD to your handler
36+
CMD [ "lambda_function.lambda_handler" ]

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ pip install -r requirements.txt
9999

100100
3. Execute com Docker:
101101
```bash
102-
docker compose up --build --watch
102+
docker build -t certified-builder . && docker run -p 9000:8080 certified-builder
103103
```
104104

105105
4. Teste localmente:

0 commit comments

Comments
 (0)