Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +18 -15
Dockerfile
CHANGED
@@ -1,27 +1,30 @@
|
|
1 |
# Use an official Python runtime as a parent image
|
2 |
-
FROM python:3.
|
3 |
|
4 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
ENV PYTHONDONTWRITEBYTECODE=1
|
6 |
ENV PYTHONUNBUFFERED=1
|
7 |
|
8 |
-
# Create a non-root user to run the app
|
9 |
-
RUN useradd -m -u 1000 appuser
|
10 |
-
USER appuser
|
11 |
-
|
12 |
# Set the working directory
|
13 |
WORKDIR /app
|
14 |
|
15 |
# Copy and install dependencies
|
16 |
-
COPY --chown=
|
17 |
-
RUN pip install --no-cache-dir --upgrade pip
|
18 |
-
|
19 |
|
20 |
-
# Copy the application code
|
21 |
-
COPY --chown=
|
22 |
|
23 |
-
# Expose the port
|
24 |
-
EXPOSE
|
25 |
|
26 |
-
#
|
27 |
-
CMD ["
|
|
|
1 |
# Use an official Python runtime as a parent image
|
2 |
+
FROM python:3.10-slim
|
3 |
|
4 |
+
# Create a user with a non-root UID
|
5 |
+
RUN useradd -m -u 1000 user
|
6 |
+
|
7 |
+
# Switch to the non-root user
|
8 |
+
USER user
|
9 |
+
|
10 |
+
# Set environment variables
|
11 |
+
ENV PATH="/home/user/.local/bin:$PATH"
|
12 |
ENV PYTHONDONTWRITEBYTECODE=1
|
13 |
ENV PYTHONUNBUFFERED=1
|
14 |
|
|
|
|
|
|
|
|
|
15 |
# Set the working directory
|
16 |
WORKDIR /app
|
17 |
|
18 |
# Copy and install dependencies
|
19 |
+
COPY --chown=user: /app/requirements.txt .
|
20 |
+
RUN pip install --no-cache-dir --upgrade pip
|
21 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
22 |
|
23 |
+
# Copy the rest of the application code
|
24 |
+
COPY --chown=user: /app /app
|
25 |
|
26 |
+
# Expose the port your app runs on
|
27 |
+
EXPOSE 8080
|
28 |
|
29 |
+
# Define the command to run the app using Gunicorn
|
30 |
+
CMD ["gunicorn", "--bind", "0.0.0.0:8080", "app:app"]
|