Prathamesh1420
commited on
Update Dockerfile
Browse files- Dockerfile +17 -19
Dockerfile
CHANGED
@@ -1,27 +1,25 @@
|
|
1 |
-
# Use
|
2 |
-
FROM python:3.
|
3 |
|
4 |
-
#
|
5 |
-
|
|
|
6 |
|
7 |
-
#
|
8 |
-
|
9 |
-
|
10 |
-
libffi-dev \
|
11 |
-
libssl-dev \
|
12 |
-
&& rm -rf /var/lib/apt/lists/*
|
13 |
|
14 |
-
#
|
15 |
-
|
|
|
|
|
|
|
16 |
|
17 |
# Install Python dependencies
|
18 |
RUN pip install --no-cache-dir -r requirements.txt
|
19 |
|
20 |
-
#
|
21 |
-
|
22 |
-
|
23 |
-
# Expose the FastAPI default port
|
24 |
-
EXPOSE 8000
|
25 |
|
26 |
-
# Command to
|
27 |
-
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "
|
|
|
1 |
+
# Use a slim Python image
|
2 |
+
FROM python:3.10-slim
|
3 |
|
4 |
+
# Add a non-root user for better security
|
5 |
+
RUN useradd user
|
6 |
+
USER user
|
7 |
|
8 |
+
# Set environment variables
|
9 |
+
ENV HOME=/home/user \
|
10 |
+
PATH=/home/user/.local/bin:$PATH
|
|
|
|
|
|
|
11 |
|
12 |
+
# Set the working directory
|
13 |
+
WORKDIR $HOME/app
|
14 |
+
|
15 |
+
# Copy application files and set ownership to the non-root user
|
16 |
+
COPY --chown=user ./ $HOME/app
|
17 |
|
18 |
# Install Python dependencies
|
19 |
RUN pip install --no-cache-dir -r requirements.txt
|
20 |
|
21 |
+
# Expose the port for FastAPI (default is 7860 as per your requirement)
|
22 |
+
EXPOSE 7860
|
|
|
|
|
|
|
23 |
|
24 |
+
# Command to start FastAPI with uvicorn, listening on port 7860
|
25 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|