Update Dockerfile
Browse files- Dockerfile +24 -21
Dockerfile
CHANGED
|
@@ -1,32 +1,35 @@
|
|
| 1 |
-
# Use
|
| 2 |
FROM python:3.9-slim
|
| 3 |
|
| 4 |
-
# Set
|
| 5 |
-
|
| 6 |
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
&& rm -rf /var/lib/apt/lists/*
|
| 12 |
|
|
|
|
|
|
|
| 13 |
|
| 14 |
-
#
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
# Copy requirements file
|
| 18 |
-
COPY requirements.txt .
|
| 19 |
|
| 20 |
-
#
|
| 21 |
-
RUN
|
| 22 |
-
python -m pip install torch torchvision -f https://download.pytorch.org/whl/cpu/torch_stable.html && \
|
| 23 |
-
python -m pip install -r requirements.txt
|
| 24 |
|
| 25 |
-
#
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
-
# Expose the
|
| 29 |
EXPOSE 8000
|
| 30 |
|
| 31 |
-
#
|
| 32 |
-
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"]
|
|
|
|
| 1 |
+
# Use an official Python runtime as a parent image
|
| 2 |
FROM python:3.9-slim
|
| 3 |
|
| 4 |
+
# Set the working directory in the container
|
| 5 |
+
WORKDIR /app
|
| 6 |
|
| 7 |
+
# Install system dependencies required for OpenCV
|
| 8 |
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 9 |
+
libgl1-mesa-glx \
|
| 10 |
+
libglib2.0-0 \
|
| 11 |
&& rm -rf /var/lib/apt/lists/*
|
| 12 |
|
| 13 |
+
# Copy the requirements.txt into the container at /app
|
| 14 |
+
COPY requirements.txt /app/
|
| 15 |
|
| 16 |
+
# Install any needed Python dependencies
|
| 17 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
+
# Create writable directories for caching and configuration
|
| 20 |
+
RUN mkdir -p /app/cache /app/config && chmod -R 777 /app/cache /app/config
|
|
|
|
|
|
|
| 21 |
|
| 22 |
+
# Set environment variables
|
| 23 |
+
ENV HF_HOME=/app/cache \
|
| 24 |
+
MPLCONFIGDIR=/app/config/matplotlib \
|
| 25 |
+
YOLO_CONFIG_DIR=/app/config/ultralytics
|
| 26 |
+
|
| 27 |
+
ENV HUGGINGFACE_HUB_ENABLE_HF_UPGRADE_CHECK=false
|
| 28 |
+
# Copy the current directory contents into the container at /app
|
| 29 |
+
COPY . /app/
|
| 30 |
|
| 31 |
+
# Expose port 8000 for the FastAPI app
|
| 32 |
EXPOSE 8000
|
| 33 |
|
| 34 |
+
# Run FastAPI app using uvicorn
|
| 35 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"]
|