Spaces:
Sleeping
Sleeping
WebashalarForML
commited on
Commit
•
eed6dfe
1
Parent(s):
ff9c3da
Update Dockerfile
Browse files- Dockerfile +24 -32
Dockerfile
CHANGED
@@ -1,41 +1,33 @@
|
|
1 |
-
# Use
|
2 |
-
FROM
|
3 |
|
4 |
-
# Set environment variables
|
5 |
-
ENV
|
6 |
-
ENV
|
7 |
|
8 |
-
#
|
9 |
-
RUN apt-get update && apt-get install -y \
|
10 |
-
python3 \
|
11 |
-
python3-pip \
|
12 |
-
python3-dev \
|
13 |
-
libgl1-mesa-glx \
|
14 |
-
libglib2.0-0 \ # Required for GLib
|
15 |
-
&& apt-get clean && rm -rf /var/lib/apt/lists/*
|
16 |
-
|
17 |
-
# Create a non-root user
|
18 |
-
RUN useradd -m user
|
19 |
-
|
20 |
-
# Set the user to the non-root user
|
21 |
-
USER user
|
22 |
-
|
23 |
-
# Set the working directory to /app
|
24 |
WORKDIR /app
|
25 |
|
26 |
-
# Copy the requirements
|
27 |
-
COPY
|
28 |
-
RUN pip3 install --no-cache-dir --upgrade -r /app/requirements.txt
|
29 |
|
30 |
-
#
|
31 |
-
|
32 |
|
33 |
-
# Create the
|
34 |
-
RUN mkdir -p /app/static/uploads /app/static/results && \
|
35 |
-
chmod -R
|
36 |
|
37 |
-
#
|
|
|
|
|
|
|
38 |
EXPOSE 7860
|
39 |
|
40 |
-
#
|
41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Use an official Python runtime as a parent image
|
2 |
+
FROM python:3.9-slim
|
3 |
|
4 |
+
# Set environment variables for Python
|
5 |
+
ENV PYTHONDONTWRITEBYTECODE 1
|
6 |
+
ENV PYTHONUNBUFFERED 1
|
7 |
|
8 |
+
# Set the working directory inside the container
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
WORKDIR /app
|
10 |
|
11 |
+
# Copy the requirements file into the container at /app
|
12 |
+
COPY requirements.txt /app/
|
|
|
13 |
|
14 |
+
# Install the dependencies specified in requirements.txt
|
15 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
16 |
|
17 |
+
# Create the necessary directories and ensure they have proper permissions
|
18 |
+
RUN mkdir -p /app/uploads /app/static/uploads /app/static/results /tmp/flask_sessions /app/flask_sessions && \
|
19 |
+
chmod -R 777 /app/uploads /app/static/uploads /app/static/results /tmp/flask_sessions /app/flask_sessions
|
20 |
|
21 |
+
# Copy the entire application code to /app
|
22 |
+
COPY . /app/
|
23 |
+
|
24 |
+
# Expose the port used by the Flask app
|
25 |
EXPOSE 7860
|
26 |
|
27 |
+
# Set environment variables for Flask
|
28 |
+
ENV FLASK_APP=app.py
|
29 |
+
ENV FLASK_ENV=production
|
30 |
+
ENV SESSION_FILE_DIR=/app/flask_sessions
|
31 |
+
|
32 |
+
# Run the application with Gunicorn, setting workers and timeout
|
33 |
+
CMD ["gunicorn", "-w", "1", "-b", "0.0.0.0:7860", "--timeout", "120", "app:app"]
|