From 5b3674b42ee7d9296a07aa0532ab2e838ba366b7 Mon Sep 17 00:00:00 2001 From: Rhett Reisman Date: Sat, 27 Jul 2024 11:22:00 -0500 Subject: [PATCH] Update Dockerfile --- Dockerfile | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1791075..1bd54cd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM amazonlinux:2023 # Install Python 3.9 and other necessary tools -RUN dnf install -y python3.9 python3.9-pip zip && \ +RUN dnf install -y python3.9 python3.9-devel gcc zip && \ dnf clean all # Set up the work directory @@ -11,18 +11,23 @@ WORKDIR /root # Copy your application code and requirements.txt into the Docker image COPY . . -# Install dependencies directly into the Lambda-compatible directory structure -RUN mkdir -p python/lib/python3.9/site-packages && \ - python3.9 -m pip install --upgrade pip setuptools wheel && \ - python3.9 -m pip install \ +# Create a virtual environment and install dependencies +RUN python3.9 -m venv /root/venv && \ + . /root/venv/bin/activate && \ + pip install --upgrade pip setuptools wheel && \ + pip install \ --platform manylinux2014_x86_64 \ --implementation cp \ --python-version 3.9 \ --only-binary=:all: --upgrade \ - -r requirements.txt -t python/lib/python3.9/site-packages && \ - python3.9 -m pip install . -t python/lib/python3.9/site-packages + -r requirements.txt && \ + pip install . && \ + deactivate # Package everything into a ZIP file -CMD cd python && \ +CMD mkdir -p python/lib/python3.9/site-packages && \ + cp -r /root/venv/lib/python3.9/site-packages/* python/lib/python3.9/site-packages/ && \ + cp -r coinbase_advanced_trader python/lib/python3.9/site-packages/ && \ + cd python && \ zip -r ../layer.zip . && \ cd .. \ No newline at end of file