Spaces:
Running
Running
Upload Dockerfile
Browse files- Dockerfile +19 -30
Dockerfile
CHANGED
@@ -1,41 +1,30 @@
|
|
1 |
-
|
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 |
-
#
|
11 |
-
|
12 |
|
13 |
-
#
|
|
|
|
|
14 |
|
15 |
-
#
|
16 |
-
|
17 |
|
18 |
# Set environment variables
|
19 |
-
ENV
|
20 |
-
|
21 |
-
|
22 |
-
# Set the working directory in the container
|
23 |
-
WORKDIR /app
|
24 |
|
25 |
-
#
|
26 |
-
|
27 |
-
&& apt-get install -y --no-install-recommends gcc libgomp1 \
|
28 |
-
&& rm -rf /var/lib/apt/lists/*
|
29 |
|
30 |
-
#
|
31 |
-
|
32 |
-
RUN pip install --no-cache-dir -r requirements.txt
|
33 |
|
34 |
-
# Copy
|
35 |
-
COPY
|
36 |
|
37 |
-
# Expose
|
38 |
-
EXPOSE
|
39 |
|
40 |
# Command to run the FastAPI application using uvicorn
|
41 |
-
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "
|
|
|
1 |
+
FROM python:3.9
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
+
# Set working directory
|
4 |
+
WORKDIR /code
|
5 |
|
6 |
+
# Copy requirements file and install dependencies
|
7 |
+
COPY ./requirements.txt /code/requirements.txt
|
8 |
+
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
9 |
|
10 |
+
# Create a non-root user
|
11 |
+
RUN useradd user
|
12 |
|
13 |
# Set environment variables
|
14 |
+
ENV HOME=/home/user \
|
15 |
+
PATH=/home/user/.local/bin:$PATH
|
|
|
|
|
|
|
16 |
|
17 |
+
# Switch to the non-root user
|
18 |
+
USER user
|
|
|
|
|
19 |
|
20 |
+
# Set working directory for the application
|
21 |
+
WORKDIR $HOME/app
|
|
|
22 |
|
23 |
+
# Copy application code into the container
|
24 |
+
COPY --chown=user . $HOME/app
|
25 |
|
26 |
+
# Expose port
|
27 |
+
EXPOSE 7860
|
28 |
|
29 |
# Command to run the FastAPI application using uvicorn
|
30 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|