Update Dockerfile
Browse files- Dockerfile +9 -12
Dockerfile
CHANGED
|
@@ -1,40 +1,37 @@
|
|
| 1 |
# Use an official Python runtime as a parent image
|
| 2 |
-
FROM python:3.
|
| 3 |
|
| 4 |
# Set the working directory to /app
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
-
# Install system dependencies for machine learning and data processing
|
| 8 |
RUN apt-get update && apt-get install -y \
|
| 9 |
build-essential \
|
| 10 |
libopenblas-dev \
|
| 11 |
libomp-dev \
|
| 12 |
&& rm -rf /var/lib/apt/lists/*
|
| 13 |
|
| 14 |
-
# Create writable cache directories
|
| 15 |
RUN mkdir -p /tmp/huggingface_cache /tmp/matplotlib
|
| 16 |
|
| 17 |
-
# Set environment variables for
|
| 18 |
ENV HF_HOME=/tmp/huggingface_cache
|
| 19 |
ENV MPLCONFIGDIR=/tmp/matplotlib
|
| 20 |
|
| 21 |
-
# Copy requirements.txt
|
| 22 |
COPY requirements.txt /app/requirements.txt
|
| 23 |
|
| 24 |
-
# Install
|
| 25 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 26 |
|
| 27 |
# Install PyTorch separately to ensure compatibility with the correct architecture
|
| 28 |
RUN pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
|
| 29 |
|
| 30 |
-
# Copy the rest of the application code
|
| 31 |
COPY . /app
|
| 32 |
|
| 33 |
-
#
|
| 34 |
-
RUN if [ ! -f "/app/bert_imdb_model.bin" ]; then echo "Error: Model file not found in container"; exit 1; fi
|
| 35 |
-
|
| 36 |
-
# Expose port 7860 for Hugging Face Spaces
|
| 37 |
EXPOSE 7860
|
| 38 |
|
| 39 |
-
#
|
| 40 |
CMD ["python", "main.py"]
|
|
|
|
| 1 |
# Use an official Python runtime as a parent image
|
| 2 |
+
FROM python:3.10-slim
|
| 3 |
|
| 4 |
# Set the working directory to /app
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
+
# Install system dependencies for machine learning and data processing
|
| 8 |
RUN apt-get update && apt-get install -y \
|
| 9 |
build-essential \
|
| 10 |
libopenblas-dev \
|
| 11 |
libomp-dev \
|
| 12 |
&& rm -rf /var/lib/apt/lists/*
|
| 13 |
|
| 14 |
+
# Create writable cache directories for Hugging Face and Matplotlib
|
| 15 |
RUN mkdir -p /tmp/huggingface_cache /tmp/matplotlib
|
| 16 |
|
| 17 |
+
# Set environment variables for cache paths
|
| 18 |
ENV HF_HOME=/tmp/huggingface_cache
|
| 19 |
ENV MPLCONFIGDIR=/tmp/matplotlib
|
| 20 |
|
| 21 |
+
# Copy requirements.txt to leverage Docker caching
|
| 22 |
COPY requirements.txt /app/requirements.txt
|
| 23 |
|
| 24 |
+
# Install dependencies
|
| 25 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 26 |
|
| 27 |
# Install PyTorch separately to ensure compatibility with the correct architecture
|
| 28 |
RUN pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
|
| 29 |
|
| 30 |
+
# Copy the rest of the application code
|
| 31 |
COPY . /app
|
| 32 |
|
| 33 |
+
# Expose port 7860 for Flask app
|
|
|
|
|
|
|
|
|
|
| 34 |
EXPOSE 7860
|
| 35 |
|
| 36 |
+
# Run the Flask application
|
| 37 |
CMD ["python", "main.py"]
|