Spaces:
Sleeping
Sleeping
Upload Dockerfile
Browse files- Dockerfile +25 -15
Dockerfile
CHANGED
@@ -1,26 +1,36 @@
|
|
1 |
# Use an official Python runtime as a parent image
|
2 |
FROM python:3.10-slim
|
3 |
|
4 |
-
# Set
|
5 |
-
WORKDIR /
|
6 |
|
7 |
-
# Copy
|
8 |
-
COPY requirements.txt /
|
9 |
|
10 |
-
# Install
|
11 |
-
RUN pip install --no-cache-dir -r requirements.txt
|
12 |
|
13 |
-
#
|
14 |
-
|
15 |
|
16 |
-
# Create a
|
17 |
-
RUN
|
18 |
|
19 |
-
#
|
20 |
-
|
21 |
|
22 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
EXPOSE 7860
|
24 |
|
25 |
-
#
|
26 |
-
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
1 |
# Use an official Python runtime as a parent image
|
2 |
FROM python:3.10-slim
|
3 |
|
4 |
+
# Set working directory within the container
|
5 |
+
WORKDIR /code
|
6 |
|
7 |
+
# Copy requirements.txt to the working directory
|
8 |
+
COPY ./requirements.txt /code/requirements.txt
|
9 |
|
10 |
+
# Install Python dependencies
|
11 |
+
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
12 |
|
13 |
+
# Install ffmpeg
|
14 |
+
RUN apt update && apt install -y ffmpeg
|
15 |
|
16 |
+
# Create a non-root user
|
17 |
+
RUN useradd -m -u 1000 user
|
18 |
|
19 |
+
# Switch to the non-root user
|
20 |
+
USER user
|
21 |
|
22 |
+
# Set environment variables
|
23 |
+
ENV HOME=/home/user \
|
24 |
+
PATH=/home/user/.local/bin:$PATH
|
25 |
+
|
26 |
+
# Set working directory for the application
|
27 |
+
WORKDIR $HOME/app
|
28 |
+
|
29 |
+
# Copy the application code to the working directory
|
30 |
+
COPY --chown=user . $HOME/app
|
31 |
+
|
32 |
+
# Expose port 7860 (assuming your FastAPI app runs on this port)
|
33 |
EXPOSE 7860
|
34 |
|
35 |
+
# Command to run the FastAPI application
|
36 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|