Skip to content

Commit

Permalink
Merge pull request #71 from rhettre/feature/release-workflow
Browse files Browse the repository at this point in the history
Update Workflow
  • Loading branch information
rhettre authored Jul 27, 2024
2 parents e6adc83 + c650284 commit 016d726
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 27 deletions.
25 changes: 17 additions & 8 deletions .github/workflows/release-lambda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
27 changes: 9 additions & 18 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
zip -r9 /asset-output/layer.zip . && \
cd /var/task
4 changes: 3 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
coinbase-advanced-py
requests >=2.31.0
urllib3 >= 2.2.2
PyYAML >= 6.0.1
PyYAML >= 6.0.1
cryptography>=42.0.4
cffi

0 comments on commit 016d726

Please sign in to comment.