Deepakraj2006 commited on
Commit
2dc3938
·
verified ·
1 Parent(s): 392695a

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +29 -11
Dockerfile CHANGED
@@ -1,20 +1,38 @@
1
- # Use an official Python runtime as a base image
2
- FROM python:3.9-slim
3
 
4
  # Set the working directory
5
  WORKDIR /app
6
 
7
- # Copy the current directory contents into the container
8
- COPY . /app
9
 
10
- # Install dependencies
11
  RUN pip install --no-cache-dir -r requirements.txt
12
 
13
- # Expose the port Flask runs on
14
- EXPOSE 8000
 
 
 
 
 
 
 
 
 
 
 
 
15
 
16
- # Define environment variable
17
- ENV FLASK_APP=app.py
 
 
 
 
 
 
18
 
19
- # Run the Flask app
20
- CMD ["python", "app.py"]
 
1
+ # Use the official Python image as the base image
2
+ FROM python:3.9
3
 
4
  # Set the working directory
5
  WORKDIR /app
6
 
7
+ # Copy the requirements file into the container
8
+ COPY requirements.txt .
9
 
10
+ # Install the dependencies
11
  RUN pip install --no-cache-dir -r requirements.txt
12
 
13
+ # Create a non-root user with a home directory
14
+ RUN useradd -m -u 1000 appuser
15
+
16
+ # Set environment variables for cache directories
17
+ ENV HF_HOME=/home/appuser/.cache/huggingface
18
+ ENV TRANSFORMERS_CACHE=/home/appuser/.cache/huggingface/transformers
19
+ ENV TORCH_HOME=/home/appuser/.cache/torch
20
+
21
+ # Create cache directories and set permissions
22
+ RUN mkdir -p $HF_HOME $TRANSFORMERS_CACHE $TORCH_HOME \
23
+ && chown -R appuser:appuser /home/appuser/.cache
24
+
25
+ # Switch to the non-root user
26
+ USER appuser
27
 
28
+ # Copy the rest of the application code
29
+ COPY . .
30
+
31
+ # Set the environment variable for the Hugging Face API token
32
+ ENV HUGGINGFACEHUB_API_TOKEN=your_huggingface_api_token
33
+
34
+ # Expose the port the app runs on
35
+ EXPOSE 8000
36
 
37
+ # Command to run the application
38
+ CMD ["python", "app.py"]