Spaces:
Sleeping
Sleeping
Create Dockerfile
Browse files- Dockerfile +30 -0
Dockerfile
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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"]
|