# Pull the base image with python 3.8 as a runtime for your Lambda FROM public.ecr.aws/lambda/python:3.8 # Copy the requirements for pip + huggingface transformers COPY requirements.txt ./ # Install the python requirements from requirements.txt RUN python3.8 -m pip install -r requirements.txt # Copy the earlier created app.py file to the container COPY app.py ./ # Load the BERT model from Huggingface and store it in the model directory, when Lambda function is invoked it will be copied to EFS. RUN mkdir model1 RUN curl -L https://huggingface.co/distilbert-base-uncased-distilled-squad/resolve/main/pytorch_model.bin -o ./model1/pytorch_model.bin RUN curl https://huggingface.co/distilbert-base-uncased-distilled-squad/resolve/main/config.json -o ./model1/config.json RUN curl https://huggingface.co/distilbert-base-uncased-distilled-squad/resolve/main/tokenizer.json -o ./model1/tokenizer.json RUN curl https://huggingface.co/distilbert-base-uncased-distilled-squad/resolve/main/tokenizer_config.json -o ./model1/tokenizer_config.json # Load a second model RUN mkdir model2 RUN curl -L https://huggingface.co/distilbert-base-cased-distilled-squad/resolve/main/pytorch_model.bin -o ./model2/pytorch_model.bin RUN curl https://huggingface.co/distilbert-base-cased-distilled-squad/resolve/main/config.json -o ./model2/config.json RUN curl https://huggingface.co/distilbert-base-cased-distilled-squad/resolve/main/tokenizer.json -o ./model2/tokenizer.json RUN curl https://huggingface.co/distilbert-base-cased-distilled-squad/resolve/main/tokenizer_config.json -o ./model2/tokenizer_config.json # Set the CMD to your handler CMD ["app.lambda_handler"]