lavanjv commited on
Commit
312e599
1 Parent(s): fd71755

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +11 -0
Dockerfile CHANGED
@@ -13,6 +13,15 @@ RUN pip install -r requirements.txt
13
  # Step 5: Expose the necessary port
14
  EXPOSE 7860
15
 
 
 
 
 
 
 
 
 
 
16
  # Create a non-root user and grant read-write permissions
17
  RUN useradd -ms /bin/bash myuser
18
  RUN chown -R myuser:myuser /app
@@ -23,5 +32,7 @@ RUN chmod -R 777 /app
23
  # Switch to the non-root user
24
  USER myuser
25
 
 
 
26
  # Step 6: Define the entry point command
27
  CMD ["flask", "run", "--host=0.0.0.0", "--port=7860"]
 
13
  # Step 5: Expose the necessary port
14
  EXPOSE 7860
15
 
16
+ # Expose the secret HUGGINGFACE_TOKEN at buildtime and use its value as the Hugging Face token
17
+ RUN --mount=type=secret,id=HUGGINGFACE_TOKEN,mode=0444,required=true \
18
+ echo "HUGGINGFACE_TOKEN=$(cat /run/secrets/HUGGINGFACE_TOKEN)" > .env
19
+
20
+ # Install huggingface-cli
21
+ RUN pip install huggingface_hub
22
+
23
+ # Login to Hugging Face using the token from the environment variable
24
+
25
  # Create a non-root user and grant read-write permissions
26
  RUN useradd -ms /bin/bash myuser
27
  RUN chown -R myuser:myuser /app
 
32
  # Switch to the non-root user
33
  USER myuser
34
 
35
+ RUN huggingface-cli login --token $HUGGINGFACE_TOKEN
36
+
37
  # Step 6: Define the entry point command
38
  CMD ["flask", "run", "--host=0.0.0.0", "--port=7860"]