Patryk Studzinski commited on
Commit
572ea40
·
1 Parent(s): 4cbe226

update dockerfile with appropriate token fetch

Browse files
Files changed (1) hide show
  1. Dockerfile +4 -11
Dockerfile CHANGED
@@ -1,34 +1,27 @@
1
 
2
  FROM python:3.9-slim
3
 
4
- # Set the working directory
5
  WORKDIR /app
6
 
7
- # Define where the model will be stored in the image
8
  ENV MODEL_DIR=/app/pretrain_model
9
  ENV HF_HUB_DISABLE_SYMLINKS_WARNING=1
 
10
 
11
- # Copy the requirements file
12
  COPY requirements.txt .
13
 
14
- # Install dependencies
15
  RUN pip install --no-cache-dir -r requirements.txt
16
 
17
- # Copy the download script into the image
18
  COPY download_model.py /app/download_model.py
19
 
20
- # Download the model using the script and the secret
21
  RUN --mount=type=secret,id=huggingface_token \
22
- echo "--- Docker RUN: Starting model download script /app/download_model.py..." && \
 
23
  python /app/download_model.py && \
24
  echo "--- Docker RUN: Model download script finished." && \
25
- rm /app/download_model.py # Optional: clean up the script after use
26
 
27
- # Copy the rest of your application code AFTER model download
28
  COPY . .
29
 
30
- # Expose the port the app runs on
31
  EXPOSE 8000
32
 
33
- # Run the application
34
  CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
 
2
  FROM python:3.9-slim
3
 
 
4
  WORKDIR /app
5
 
 
6
  ENV MODEL_DIR=/app/pretrain_model
7
  ENV HF_HUB_DISABLE_SYMLINKS_WARNING=1
8
+ ENV HUGGING_FACE_HUB_TOKEN=""
9
 
 
10
  COPY requirements.txt .
11
 
 
12
  RUN pip install --no-cache-dir -r requirements.txt
13
 
 
14
  COPY download_model.py /app/download_model.py
15
 
 
16
  RUN --mount=type=secret,id=huggingface_token \
17
+ export HUGGING_FACE_HUB_TOKEN=$(cat /run/secrets/huggingface_token) && \
18
+ echo "--- Docker RUN: Starting model download script (token is now in ENV)..." && \
19
  python /app/download_model.py && \
20
  echo "--- Docker RUN: Model download script finished." && \
21
+ rm /app/download_model.py
22
 
 
23
  COPY . .
24
 
 
25
  EXPOSE 8000
26
 
 
27
  CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]