Spaces:
Runtime error
Runtime error
Create Dockerfile
Browse files- Dockerfile +42 -0
Dockerfile
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Use an official Python runtime as a parent image
|
| 2 |
+
FROM python:3.9-slim
|
| 3 |
+
|
| 4 |
+
# Disable Python buffering for easier container logging
|
| 5 |
+
ENV PYTHONUNBUFFERED=1
|
| 6 |
+
|
| 7 |
+
# Set environment variables for writable caches and config directories
|
| 8 |
+
ENV HOME=/tmp
|
| 9 |
+
ENV XDG_CACHE_HOME=/tmp/.cache
|
| 10 |
+
ENV MPLCONFIGDIR=/tmp/matplotlib
|
| 11 |
+
ENV HF_HOME=/tmp/hf_home
|
| 12 |
+
|
| 13 |
+
# Set the working directory in the container
|
| 14 |
+
WORKDIR /app
|
| 15 |
+
|
| 16 |
+
# Install system dependencies (ffmpeg is needed for video processing, libsm6/libxext6 support image/video)
|
| 17 |
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 18 |
+
ffmpeg \
|
| 19 |
+
libsm6 \
|
| 20 |
+
libxext6 \
|
| 21 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 22 |
+
|
| 23 |
+
# Copy the requirements file into the container
|
| 24 |
+
COPY requirements.txt /app/requirements.txt
|
| 25 |
+
|
| 26 |
+
# Upgrade pip and install Python dependencies
|
| 27 |
+
RUN pip install --upgrade pip && pip install --no-cache-dir -r requirements.txt
|
| 28 |
+
|
| 29 |
+
# Download spaCy's small English model
|
| 30 |
+
RUN python -m spacy download en_core_web_sm
|
| 31 |
+
|
| 32 |
+
# Create required directories with proper permissions
|
| 33 |
+
RUN mkdir -p /app/static /app/temp && chmod -R 777 /app/static /app/temp
|
| 34 |
+
|
| 35 |
+
# Copy the rest of your application code into the container
|
| 36 |
+
COPY . /app
|
| 37 |
+
|
| 38 |
+
# Expose the port your app runs on
|
| 39 |
+
EXPOSE 8500
|
| 40 |
+
|
| 41 |
+
# Run the FastAPI application using uvicorn
|
| 42 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8500"]
|