aradhyapavan commited on
Commit
19f763f
·
verified ·
1 Parent(s): ca2c89c

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +54 -55
Dockerfile CHANGED
@@ -1,55 +1,54 @@
1
- # Use Python 3.9 slim image for better performance
2
- FROM python:3.11-slim
3
-
4
- # Set environment variables
5
- ENV PYTHONUNBUFFERED=1
6
- ENV PYTHONDONTWRITEBYTECODE=1
7
- ENV HF_HOME=/tmp/huggingface
8
- ENV TRANSFORMERS_CACHE=/tmp/huggingface/transformers
9
- ENV TORCH_HOME=/tmp/torch
10
-
11
- # Create a non-root user (required for HF Spaces)
12
- RUN useradd -m -u 1000 user
13
- USER user
14
- ENV HOME=/home/user
15
- ENV PATH=/home/user/.local/bin:$PATH
16
-
17
- # Set working directory
18
- WORKDIR $HOME/app
19
-
20
- # Install system dependencies (as root)
21
- USER root
22
- RUN apt-get update && apt-get install -y \
23
- build-essential \
24
- curl \
25
- software-properties-common \
26
- git \
27
- && rm -rf /var/lib/apt/lists/*
28
-
29
- # Switch back to user
30
- USER user
31
-
32
- # Copy requirements and install Python dependencies
33
- COPY --chown=user requirements.txt .
34
- RUN pip install --no-cache-dir --upgrade pip
35
- RUN pip install --no-cache-dir --upgrade -r requirements.txt
36
-
37
- # Download spaCy model
38
- RUN python -m spacy download en_core_web_sm
39
-
40
- # Copy application code
41
- COPY --chown=user . .
42
-
43
- # Create cache directories
44
- RUN mkdir -p /tmp/huggingface/transformers
45
- RUN mkdir -p /tmp/torch
46
-
47
- # Expose port
48
- EXPOSE 7860
49
-
50
- # Health check
51
- HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
52
- CMD curl -f http://localhost:7860/ || exit 1
53
-
54
- # Run the Flask application
55
- CMD ["python", "app.py"]
 
1
+ # Use Python 3.9 slim image for better performance
2
+ FROM python:3.11-slim
3
+
4
+ # Set environment variables
5
+ ENV PYTHONUNBUFFERED=1
6
+ ENV PYTHONDONTWRITEBYTECODE=1
7
+ ENV HF_HOME=/tmp/huggingface
8
+ ENV TRANSFORMERS_CACHE=/tmp/huggingface/transformers
9
+ ENV TORCH_HOME=/tmp/torch
10
+
11
+ # Create a non-root user (required for HF Spaces)
12
+ RUN useradd -m -u 1000 user
13
+ USER user
14
+ ENV HOME=/home/user
15
+ ENV PATH=/home/user/.local/bin:$PATH
16
+
17
+ # Set working directory
18
+ WORKDIR $HOME/app
19
+
20
+ # Install system dependencies (as root)
21
+ USER root
22
+ RUN apt-get update && apt-get install -y \
23
+ build-essential \
24
+ curl \
25
+ git \
26
+ && rm -rf /var/lib/apt/lists/*
27
+
28
+ # Switch back to user
29
+ USER user
30
+
31
+ # Copy requirements and install Python dependencies
32
+ COPY --chown=user requirements.txt .
33
+ RUN pip install --no-cache-dir --upgrade pip
34
+ RUN pip install --no-cache-dir --upgrade -r requirements.txt
35
+
36
+ # Download spaCy model
37
+ RUN python -m spacy download en_core_web_sm
38
+
39
+ # Copy application code
40
+ COPY --chown=user . .
41
+
42
+ # Create cache directories
43
+ RUN mkdir -p /tmp/huggingface/transformers
44
+ RUN mkdir -p /tmp/torch
45
+
46
+ # Expose port
47
+ EXPOSE 7860
48
+
49
+ # Health check
50
+ HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
51
+ CMD curl -f http://localhost:7860/ || exit 1
52
+
53
+ # Run the Flask application
54
+ CMD ["python", "app.py"]