From c650284361926b1c28fcd8cd1f39ccb709719695 Mon Sep 17 00:00:00 2001 From: Rhett Reisman Date: Sat, 27 Jul 2024 12:46:37 -0500 Subject: [PATCH] Update Workflow --- .github/workflows/release-lambda.yml | 25 +++++++++++++++++-------- Dockerfile | 27 +++++++++------------------ requirements.txt | 4 +++- 3 files changed, 29 insertions(+), 27 deletions(-) diff --git a/.github/workflows/release-lambda.yml b/.github/workflows/release-lambda.yml index 727e847..abf6b8e 100644 --- a/.github/workflows/release-lambda.yml +++ b/.github/workflows/release-lambda.yml @@ -8,18 +8,27 @@ on: jobs: build-and-upload: runs-on: ubuntu-latest + strategy: + matrix: + architecture: [amd64, arm64] steps: - name: Checkout code uses: actions/checkout@v2 - - name: Build Docker Image - run: | - docker build -t lambda-layer-builder -f Dockerfile . + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 - - name: Create Lambda Layer Zip + - name: Build Docker Image and Create Lambda Layer run: | - docker run --name layer_builder lambda-layer-builder - docker cp layer_builder:/root/layer.zip . + docker buildx build --platform linux/${{ matrix.architecture }} \ + -t lambda-layer-builder:${{ matrix.architecture }} \ + --output type=docker \ + -f Dockerfile . + docker create --name layer_builder lambda-layer-builder:${{ matrix.architecture }} + docker cp layer_builder:/asset-output/layer.zip layer-${{ matrix.architecture }}.zip - name: Get Release id: get_release @@ -40,6 +49,6 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ steps.get_release.outputs.upload_url }} - asset_path: ./layer.zip - asset_name: layer-${{ github.ref_name }}.zip + asset_path: ./layer-${{ matrix.architecture }}.zip + asset_name: layer-${{ github.ref_name }}-${{ matrix.architecture }}.zip asset_content_type: application/zip \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 3f02c58..38bf024 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,35 +1,26 @@ # Use the Amazon Linux 2023 image compatible with AWS Lambda -FROM amazonlinux:2023 - -# Install Python 3.9 and other necessary tools -RUN dnf install -y python3.9 python3.9-devel gcc zip && \ - dnf clean all +FROM public.ecr.aws/lambda/python:3.9 # Set up the work directory -WORKDIR /root +WORKDIR /var/task # Copy your application code and requirements.txt into the Docker image COPY . . -# Create a virtual environment and install dependencies -RUN python3.9 -m venv /root/venv && \ - . /root/venv/bin/activate && \ - pip install --upgrade pip setuptools wheel && \ +# Install dependencies +RUN pip install --upgrade pip setuptools wheel && \ pip install -r requirements.txt && \ - pip install . && \ - deactivate + pip install . # Package everything into a ZIP file -CMD . /root/venv/bin/activate && \ - mkdir -p python/lib/python3.9/site-packages && \ +CMD mkdir -p python/lib/python3.9/site-packages && \ pip install \ - --platform manylinux2014_x86_64 \ + --platform manylinux2014_$(uname -m) \ --implementation cp \ --python-version 3.9 \ --only-binary=:all: --upgrade \ -r requirements.txt -t python/lib/python3.9/site-packages && \ pip install . -t python/lib/python3.9/site-packages && \ cd python/lib/python3.9/site-packages && \ - zip -r9 ../../../../layer.zip . && \ - cd ../../../../ && \ - deactivate \ No newline at end of file + zip -r9 /asset-output/layer.zip . && \ + cd /var/task \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 1f0feec..ac73951 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,6 @@ coinbase-advanced-py requests >=2.31.0 urllib3 >= 2.2.2 -PyYAML >= 6.0.1 \ No newline at end of file +PyYAML >= 6.0.1 +cryptography>=42.0.4 +cffi \ No newline at end of file