Spaces:
Running
Running
Upload Dockerfile
Browse files- Dockerfile +29 -29
Dockerfile
CHANGED
@@ -1,29 +1,29 @@
|
|
1 |
-
FROM python:3.9.18
|
2 |
-
|
3 |
-
WORKDIR /
|
4 |
-
|
5 |
-
# Copy requirements.txt to the container
|
6 |
-
COPY requirements.txt ./
|
7 |
-
|
8 |
-
# Install Python dependencies
|
9 |
-
RUN pip install --no-cache-dir -r requirements.txt
|
10 |
-
|
11 |
-
# Add a non-root user to run the application
|
12 |
-
RUN useradd -m -u 1000 user
|
13 |
-
|
14 |
-
# Set the user and home directory environment variables
|
15 |
-
USER user
|
16 |
-
ENV HOME=/home/user \
|
17 |
-
PATH=/home/user/.local/bin:$PATH
|
18 |
-
|
19 |
-
# Create the application directory
|
20 |
-
WORKDIR $HOME/app
|
21 |
-
|
22 |
-
# Copy the application code and model files
|
23 |
-
COPY --chown=user . $HOME/app/
|
24 |
-
|
25 |
-
# Expose the port the FastAPI app runs on
|
26 |
-
EXPOSE 7860
|
27 |
-
|
28 |
-
# Command to run the FastAPI app
|
29 |
-
CMD ["uvicorn", "
|
|
|
1 |
+
FROM python:3.9.18
|
2 |
+
|
3 |
+
WORKDIR /
|
4 |
+
|
5 |
+
# Copy requirements.txt to the container
|
6 |
+
COPY requirements.txt ./
|
7 |
+
|
8 |
+
# Install Python dependencies
|
9 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
10 |
+
|
11 |
+
# Add a non-root user to run the application
|
12 |
+
RUN useradd -m -u 1000 user
|
13 |
+
|
14 |
+
# Set the user and home directory environment variables
|
15 |
+
USER user
|
16 |
+
ENV HOME=/home/user \
|
17 |
+
PATH=/home/user/.local/bin:$PATH
|
18 |
+
|
19 |
+
# Create the application directory
|
20 |
+
WORKDIR $HOME/app
|
21 |
+
|
22 |
+
# Copy the application code and model files
|
23 |
+
COPY --chown=user . $HOME/app/
|
24 |
+
|
25 |
+
# Expose the port the FastAPI app runs on
|
26 |
+
EXPOSE 7860
|
27 |
+
|
28 |
+
# Command to run the FastAPI app
|
29 |
+
CMD ["uvicorn", "safety_classifier:app", "--host", "0.0.0.0", "--port", "7860"]
|