Update Dockerfile
Browse files- Dockerfile +23 -17
Dockerfile
CHANGED
|
@@ -1,26 +1,32 @@
|
|
| 1 |
-
#
|
| 2 |
-
FROM python:3-slim
|
| 3 |
|
| 4 |
-
|
|
|
|
| 5 |
|
| 6 |
-
#
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
-
#
|
| 10 |
-
|
| 11 |
|
| 12 |
-
#
|
| 13 |
COPY requirements.txt .
|
| 14 |
-
RUN python -m pip install -r requirements.txt
|
| 15 |
|
| 16 |
-
|
| 17 |
-
|
|
|
|
|
|
|
| 18 |
|
| 19 |
-
#
|
| 20 |
-
|
| 21 |
-
RUN adduser -u 5678 --disabled-password --gecos "" appuser && chown -R appuser /app
|
| 22 |
-
USER appuser
|
| 23 |
|
|
|
|
|
|
|
| 24 |
|
| 25 |
-
#
|
| 26 |
-
CMD ["
|
|
|
|
| 1 |
+
# Use a specific version of Python (e.g., Python 3.9 for better compatibility with PyTorch)
|
| 2 |
+
FROM python:3.9-slim
|
| 3 |
|
| 4 |
+
# Set environment variables to avoid interactive prompts
|
| 5 |
+
ENV DEBIAN_FRONTEND=noninteractive
|
| 6 |
|
| 7 |
+
# Install required system dependencies
|
| 8 |
+
RUN apt-get update && apt-get install -y \
|
| 9 |
+
libgl1-mesa-glx \ # For OpenCV compatibility
|
| 10 |
+
libglib2.0-0 \ # For OpenCV compatibility
|
| 11 |
+
build-essential \ # For building certain Python packages
|
| 12 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 13 |
|
| 14 |
+
# Set the working directory
|
| 15 |
+
WORKDIR /app
|
| 16 |
|
| 17 |
+
# Copy requirements file
|
| 18 |
COPY requirements.txt .
|
|
|
|
| 19 |
|
| 20 |
+
# Install Python dependencies
|
| 21 |
+
RUN python -m pip install --upgrade pip && \
|
| 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 |
+
# Copy the application code
|
| 26 |
+
COPY . .
|
|
|
|
|
|
|
| 27 |
|
| 28 |
+
# Expose the application port
|
| 29 |
+
EXPOSE 8000
|
| 30 |
|
| 31 |
+
# Command to run the application
|
| 32 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"]
|