switch actions file to not use arm64

This commit is contained in:
Khalim Conn-Kowlessar 2023-08-24 20:22:16 +01:00
parent 33a6587e70
commit d9b856a5ba
2 changed files with 24 additions and 10 deletions

View file

@ -66,13 +66,13 @@ jobs:
- name: Setup Docker
uses: docker/setup-buildx-action@v1
- name: Setup Docker Buildx
run: |
docker buildx create --use
# - name: Setup Docker Buildx
# run: |
# docker buildx create --use
- name: Build Docker Image
run: |
docker buildx build --platform linux/arm64 -t fastapi-lambda-image:${{ github.sha }} -f backend/docker/lambda.Dockerfile . --load
docker build -t fastapi-lambda-image:${{ github.sha }} -f backend/docker/lambda.Dockerfile . --load
- name: Login to ECR
run: |

View file

@ -1,5 +1,5 @@
# Pull base image
FROM python:3.10.12-slim-buster
FROM python:3.10.12-slim-buster as build-image
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
@ -9,7 +9,7 @@ ENV PYTHONUNBUFFERED 1
WORKDIR var/task/Model
# Install system dependencies
RUN apt-get update && apt-get install -y netcat-openbsd
RUN #apt-get update && apt-get install -y netcat-openbsd
# Install python dependencies
COPY ./backend/requirements/base.txt ./backend/requirements/base.txt
@ -17,8 +17,20 @@ RUN pip install --upgrade pip
# Install and clean up temp caches
RUN pip install -r backend/requirements/base.txt && rm -rf /root/.cache
# When running locally, we need boto3
RUN pip install boto3
# Since we are not using a base AWS image, there is some additional setup required. We need to set up the runtime
# interface client
# https://docs.aws.amazon.com/lambda/latest/dg/python-image.html#python-image-clients
# Additionally install the AWS Lambda RIC
RUN pip install awslambdaric
# Second stage: "runtime-image"
FROM python:3.10.12-slim-buster
# Set work directory to the root of your project
WORKDIR /var/task/Model
# Copy the python dependencies from the build-image
COPY --from=build-image /usr/local/lib/python3.10/site-packages/ /usr/local/lib/python3.10/site-packages/
# Copy project files
COPY ./backend/ ./backend
@ -33,5 +45,7 @@ COPY ./model_data/epc_attributes/ ./model_data/epc_attributes/
COPY ./datatypes/ ./datatypes/
COPY ./utils/ ./utils/
# command to run on container start
CMD ["uvicorn", "backend.app.main:app", "--host", "0.0.0.0", "--port", "8000"]
# Set the ENTRYPOINT to the AWS Lambda RIC and CMD to your function handler
ENTRYPOINT [ "/usr/local/bin/python", "-m", "awslambdaric" ]
# Define the handler location
CMD ["backend.app.main.handler"]