Spaces:
Runtime error
Runtime error
Upload Dockerfile
Browse files- Dockerfile +40 -12
Dockerfile
CHANGED
|
@@ -1,13 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
FROM python:3.9
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# FROM python:3.9
|
| 2 |
+
# WORKDIR /code
|
| 3 |
+
# COPY ./requirements.txt /code/requirements.txt
|
| 4 |
+
# RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
| 5 |
+
# RUN useradd user
|
| 6 |
+
# USER user
|
| 7 |
+
# ENV HOME = /home/user \
|
| 8 |
+
# PATH=/home/user/.local/bin:$PATH
|
| 9 |
+
|
| 10 |
+
# WORKDIR $HOME/app
|
| 11 |
+
# COPY --chown==user . $HOME/app
|
| 12 |
+
|
| 13 |
+
# CMD [ "uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860" ]
|
| 14 |
+
|
| 15 |
+
# Use the official Python image from Docker Hub
|
| 16 |
FROM python:3.9
|
| 17 |
+
|
| 18 |
+
# Set environment variables
|
| 19 |
+
ENV PYTHONDONTWRITEBYTECODE 1
|
| 20 |
+
ENV PYTHONUNBUFFERED 1
|
| 21 |
+
|
| 22 |
+
# Set the working directory in the container
|
| 23 |
+
WORKDIR /app
|
| 24 |
+
|
| 25 |
+
# Install system dependencies
|
| 26 |
+
RUN apt-get update \
|
| 27 |
+
&& apt-get install -y --no-install-recommends gcc libgomp1 \
|
| 28 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 29 |
+
|
| 30 |
+
# Install Python dependencies
|
| 31 |
+
COPY requirements.txt .
|
| 32 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 33 |
+
|
| 34 |
+
# Copy the FastAPI application code into the container
|
| 35 |
+
COPY app.py /app/
|
| 36 |
+
|
| 37 |
+
# Expose the port that FastAPI will run on
|
| 38 |
+
EXPOSE 8000
|
| 39 |
+
|
| 40 |
+
# Command to run the FastAPI application using uvicorn
|
| 41 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"]
|