Skip to content
This repository has been archived by the owner on Sep 25, 2024. It is now read-only.

Commit

Permalink
Downgrade to 3.9
Browse files Browse the repository at this point in the history
  • Loading branch information
edhgoose committed Apr 22, 2024
1 parent 30ce66e commit f122d77
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 25 deletions.
27 changes: 3 additions & 24 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,42 +1,21 @@
FROM amazonlinux:2023 as builder

# Set up working directories
RUN mkdir -p /opt/python

# Install packages
RUN dnf update -y
RUN dnf install -y gcc openssl-devel bzip2-devel libffi-devel zlib-devel wget make tar xz

# Download and install Python 3.12
WORKDIR /opt
RUN wget https://www.python.org/ftp/python/3.12.1/Python-3.12.1.tar.xz
RUN tar xvf Python-3.12.1.tar.xz
WORKDIR /opt/Python-3.12.1
RUN ./configure --enable-optimizations --prefix=/opt/python
RUN make -j
RUN make install

FROM amazonlinux:2023

# Set up working directories
RUN mkdir -p /opt/app
RUN mkdir -p /opt/app/build
RUN mkdir -p /opt/app/bin/

# Copy over the python binaries
COPY --from=builder /opt/python /opt/python

# Copy in the lambda source
WORKDIR /opt/app
COPY ./*.py /opt/app/
COPY requirements.txt /opt/app/requirements.txt

# Install packages
RUN dnf update -y
RUN dnf install -y cpio openssl bzip2 libffi yum-utils zip unzip less
RUN dnf install -y cpio openssl bzip2 libffi yum-utils zip unzip less pip

# This had --no-cache-dir, tracing through multiple tickets led to a problem in wheel
RUN /opt/python/bin/pip3 install -r requirements.txt
RUN pip3 install -r requirements.txt
RUN rm -rf /root/.cache/pip

# Download libraries we need to run in lambda
Expand All @@ -58,7 +37,7 @@ RUN echo "CompressLocalDatabase yes" >> /opt/app/bin/freshclam.conf
WORKDIR /opt/app
RUN zip -r9 --exclude="*test*" /opt/app/build/lambda.zip *.py bin

WORKDIR /opt/python/lib/python3.12/site-packages
WORKDIR /usr/local/lib/python3.9/site-packages
RUN zip -r9 /opt/app/build/lambda.zip *

WORKDIR /opt/app
3 changes: 2 additions & 1 deletion common.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,5 @@ def create_dir(path):


def get_timestamp():
return datetime.datetime.now(datetime.UTC).strftime("%Y/%m/%d %H:%M:%S UTC")
# replace with datetime.utc when upgrading to 3.11
return datetime.datetime.now(datetime.timezone.utc).strftime("%Y/%m/%d %H:%M:%S UTC")

0 comments on commit f122d77

Please sign in to comment.