Skip to content

Commit

Permalink
Update release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
rhettre committed Jul 27, 2024
1 parent 05c0cd2 commit 7fec6de
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 35 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/release-lambda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Install unzip
run: sudo apt-get update && sudo apt-get install -y unzip

- name: Build Docker Image and Create Lambda Layer
run: |
docker buildx build --platform linux/${{ matrix.architecture }} \
-t lambda-layer-builder:${{ matrix.architecture }} \
--output type=docker \
--load \
-f Dockerfile .
docker create --name layer_builder lambda-layer-builder:${{ matrix.architecture }}
docker cp layer_builder:/tmp/layer.zip layer-${{ matrix.architecture }}.zip
Expand Down
41 changes: 7 additions & 34 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,52 +1,25 @@
# Use the Amazon Linux 2023 image compatible with AWS Lambda
FROM public.ecr.aws/lambda/python:3.9

# Set up the work directory
WORKDIR /var/task

# Install necessary build tools, Rust, and OpenSSL
RUN yum install -y zip gcc python3-devel libffi-devel tar gzip make && \
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && \
echo 'source $HOME/.cargo/env' >> $HOME/.bashrc && \
source $HOME/.cargo/env && \
yum install -y wget && \
wget https://www.openssl.org/source/openssl-1.1.1k.tar.gz && \
tar -xzvf openssl-1.1.1k.tar.gz && \
cd openssl-1.1.1k && \
./config --prefix=/usr/local/ssl --openssldir=/usr/local/ssl shared zlib && \
make && make install && \
echo "/usr/local/ssl/lib" > /etc/ld.so.conf.d/openssl-1.1.1k.conf && \
ldconfig && \
cd .. && rm -rf openssl-1.1.1k*
COPY requirements.txt .

# Set OpenSSL environment variables
ENV LDFLAGS="-L/usr/local/ssl/lib"
ENV CPPFLAGS="-I/usr/local/ssl/include"
ENV LD_LIBRARY_PATH="/usr/local/ssl/lib"
ENV PATH="/usr/local/ssl/bin:${PATH}"
RUN pip install --upgrade pip && \
pip install --no-cache-dir -r requirements.txt

# Copy your application code and requirements.txt into the Docker image
COPY . .

# Install dependencies and create the layer
RUN source $HOME/.cargo/env && \
pip install --upgrade pip setuptools wheel && \
pip install -r requirements.txt && \
pip install . && \
RUN pip install . && \
mkdir -p /tmp/python && \
pip install \
--platform manylinux2014_$(uname -m) \
--platform manylinux2014_x86_64 \
--implementation cp \
--python-version 3.9 \
--only-binary=:all: --upgrade \
-r requirements.txt -t /tmp/python && \
pip install cffi --no-binary cffi -t /tmp/python && \
pip install cryptography --no-binary cryptography -t /tmp/python && \
pip install . -t /tmp/python && \
cd /tmp/python && \
find . -type d -name "__pycache__" -exec rm -rf {} + && \
zip -r9 /tmp/layer.zip . && \
cd /var/task
zip -r9 /tmp/layer.zip .

# Copy the layer.zip to a known location
CMD cp /tmp/layer.zip /asset-output/layer.zip
CMD ["python3", "-m", "awslambdaric", "handler.lambda_handler"]

0 comments on commit 7fec6de

Please sign in to comment.