Update Dockerfile
Browse files- Dockerfile +18 -18
Dockerfile
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
|
|
| 1 |
FROM python:3.9-slim
|
| 2 |
|
| 3 |
-
#
|
| 4 |
-
RUN
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
# Set environment variables
|
| 7 |
-
ENV
|
| 8 |
-
PATH=/home/user/.local/bin:$PATH \
|
| 9 |
-
PYTHONUNBUFFERED=1
|
| 10 |
|
| 11 |
-
#
|
| 12 |
-
WORKDIR /
|
| 13 |
|
| 14 |
-
# Copy the requirements file
|
| 15 |
COPY requirements.txt ./
|
| 16 |
-
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
| 17 |
-
|
| 18 |
-
# Change ownership of the working directory to the user
|
| 19 |
-
COPY --chown=user . /code/
|
| 20 |
|
| 21 |
-
#
|
| 22 |
-
|
| 23 |
|
| 24 |
-
#
|
| 25 |
-
|
| 26 |
|
| 27 |
-
# Expose the port that
|
| 28 |
EXPOSE 7860
|
| 29 |
|
| 30 |
-
# Command to run the FastAPI application
|
| 31 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
|
| 1 |
+
# Use the official Python image as a base
|
| 2 |
FROM python:3.9-slim
|
| 3 |
|
| 4 |
+
# Install necessary system dependencies
|
| 5 |
+
RUN apt-get update && apt-get install -y \
|
| 6 |
+
gcc \
|
| 7 |
+
build-essential \
|
| 8 |
+
libffi-dev \
|
| 9 |
+
libssl-dev \
|
| 10 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 11 |
|
| 12 |
# Set environment variables
|
| 13 |
+
ENV PYTHONUNBUFFERED=1
|
|
|
|
|
|
|
| 14 |
|
| 15 |
+
# Create and set the working directory
|
| 16 |
+
WORKDIR /app
|
| 17 |
|
| 18 |
+
# Copy the requirements file first to leverage Docker cache
|
| 19 |
COPY requirements.txt ./
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
+
# Install Python dependencies
|
| 22 |
+
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
| 23 |
|
| 24 |
+
# Copy the application code to the container
|
| 25 |
+
COPY . .
|
| 26 |
|
| 27 |
+
# Expose the port that FastAPI will run on
|
| 28 |
EXPOSE 7860
|
| 29 |
|
| 30 |
+
# Command to run the FastAPI application with Uvicorn
|
| 31 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|