seanpedrickcase commited on
Commit
00db72b
·
1 Parent(s): c9da99d

Further optimised Dockerfile and requirements (smaller torch installation now hopefully)

Browse files
Files changed (2) hide show
  1. Dockerfile +7 -4
  2. requirements_aws.txt +2 -2
Dockerfile CHANGED
@@ -1,5 +1,5 @@
1
  # Stage 1: Build dependencies and download models
2
- FROM python:3.11.9-slim-bookworm AS builder
3
 
4
  # Install Lambda web adapter in case you want to run with with an AWS Lamba function URL (not essential if not using Lambda)
5
  #COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.8.3 /lambda-adapter /opt/extensions/lambda-adapter
@@ -16,8 +16,11 @@ WORKDIR /src
16
  COPY requirements_aws.txt .
17
  RUN pip install --no-cache-dir --target=/install -r requirements_aws.txt
18
 
19
- # Install Gradio
20
- #RUN pip install --no-cache-dir --target=/install gradio==4.41.0
 
 
 
21
 
22
  # Download models (using your download_model.py script)
23
  COPY download_model.py /src/download_model.py
@@ -26,7 +29,7 @@ RUN python /src/download_model.py
26
  RUN rm requirements_aws.txt download_model.py
27
 
28
  # Stage 2: Final runtime image
29
- FROM python:3.11.9-slim-bookworm
30
 
31
  # Create a non-root user
32
  RUN useradd -m -u 1000 user
 
1
  # Stage 1: Build dependencies and download models
2
+ FROM public.ecr.aws/docker/library/python:3.11.9-slim-bookworm AS builder
3
 
4
  # Install Lambda web adapter in case you want to run with with an AWS Lamba function URL (not essential if not using Lambda)
5
  #COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.8.3 /lambda-adapter /opt/extensions/lambda-adapter
 
16
  COPY requirements_aws.txt .
17
  RUN pip install --no-cache-dir --target=/install -r requirements_aws.txt
18
 
19
+ # Install sentence-transformers without dependencies
20
+ RUN pip install --no-cache-dir sentence-transformers==3.0.1 --no-deps
21
+
22
+ # Add /install to the PYTHONPATH
23
+ ENV PYTHONPATH="/install:${PYTHONPATH}"
24
 
25
  # Download models (using your download_model.py script)
26
  COPY download_model.py /src/download_model.py
 
29
  RUN rm requirements_aws.txt download_model.py
30
 
31
  # Stage 2: Final runtime image
32
+ FROM public.ecr.aws/docker/library/python:3.11.9-slim-bookworm
33
 
34
  # Create a non-root user
35
  RUN useradd -m -u 1000 user
requirements_aws.txt CHANGED
@@ -1,8 +1,9 @@
 
1
  boto3==1.34.158
2
  bertopic==0.16.2
3
  spacy==3.7.5
4
  en_core_web_sm @ https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.7.1/en_core_web_sm-3.7.1.tar.gz
5
- gradio # Not specified version due to possible conflict with spacy
6
  pyarrow==14.0.2
7
  openpyxl==3.1.2
8
  Faker==22.2.0
@@ -10,5 +11,4 @@ presidio_analyzer==2.2.354
10
  presidio_anonymizer==2.2.354
11
  scipy==1.11.4
12
  polars==0.20.6
13
- sentence-transformers==3.0.1
14
  numpy==1.26.4
 
1
+ torch==2.4.0 --index-url https://download.pytorch.org/whl/cpu
2
  boto3==1.34.158
3
  bertopic==0.16.2
4
  spacy==3.7.5
5
  en_core_web_sm @ https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.7.1/en_core_web_sm-3.7.1.tar.gz
6
+ gradio>=4.26.0
7
  pyarrow==14.0.2
8
  openpyxl==3.1.2
9
  Faker==22.2.0
 
11
  presidio_anonymizer==2.2.354
12
  scipy==1.11.4
13
  polars==0.20.6
 
14
  numpy==1.26.4