Spaces:
Runtime error
Runtime error
Update Dockerfile
Browse files- Dockerfile +11 -17
Dockerfile
CHANGED
|
@@ -1,43 +1,37 @@
|
|
| 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 |
-
ENV MPLCONFIGDIR=/app/.config/matplotlib
|
| 8 |
|
| 9 |
-
# Set the working directory
|
| 10 |
WORKDIR /app
|
| 11 |
|
| 12 |
-
# Install system dependencies
|
| 13 |
RUN apt-get update && apt-get install -y \
|
| 14 |
-
libgl1 \
|
| 15 |
-
|
| 16 |
-
libsm6 \
|
| 17 |
-
libxext6 \
|
| 18 |
-
libxrender1 \
|
| 19 |
&& rm -rf /var/lib/apt/lists/*
|
| 20 |
|
| 21 |
# Copy the requirements file into the container at /app
|
| 22 |
COPY requirements.txt /app/
|
| 23 |
|
| 24 |
-
# Install
|
| 25 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 26 |
|
| 27 |
-
# Create
|
| 28 |
-
RUN mkdir -p /app/
|
| 29 |
-
chmod -R 777 /app/uploads /app/static/uploads /app/static/results /tmp/flask_sessions /app/flask_sessions /app/models /app/.config/matplotlib
|
| 30 |
|
| 31 |
-
# Copy the
|
| 32 |
COPY . /app/
|
| 33 |
|
| 34 |
-
# Expose the port
|
| 35 |
EXPOSE 7860
|
| 36 |
|
| 37 |
# Set environment variables for Flask
|
| 38 |
ENV FLASK_APP=app.py
|
| 39 |
ENV FLASK_ENV=production
|
| 40 |
-
ENV SESSION_FILE_DIR=/app/flask_sessions
|
| 41 |
|
| 42 |
-
#
|
| 43 |
CMD ["gunicorn", "-w", "1", "-b", "0.0.0.0:7860", "--timeout", "120", "app:app"]
|
|
|
|
| 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
|
| 9 |
WORKDIR /app
|
| 10 |
|
| 11 |
+
# Install system dependencies, including libgomp
|
| 12 |
RUN apt-get update && apt-get install -y \
|
| 13 |
+
libgl1-mesa-glx \
|
| 14 |
+
libgomp1 \
|
|
|
|
|
|
|
|
|
|
| 15 |
&& rm -rf /var/lib/apt/lists/*
|
| 16 |
|
| 17 |
# Copy the requirements file into the container at /app
|
| 18 |
COPY requirements.txt /app/
|
| 19 |
|
| 20 |
+
# Install any needed packages specified in requirements.txt
|
| 21 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 22 |
|
| 23 |
+
# Create directories for session storage and uploads
|
| 24 |
+
RUN mkdir -p /app/flask_sessions /app/uploads && chmod -R 777 /app/flask_sessions /app/uploads
|
|
|
|
| 25 |
|
| 26 |
+
# Copy the rest of the application code to /app
|
| 27 |
COPY . /app/
|
| 28 |
|
| 29 |
+
# Expose the port that the app runs on
|
| 30 |
EXPOSE 7860
|
| 31 |
|
| 32 |
# Set environment variables for Flask
|
| 33 |
ENV FLASK_APP=app.py
|
| 34 |
ENV FLASK_ENV=production
|
|
|
|
| 35 |
|
| 36 |
+
# Command to run the Flask app using Gunicorn
|
| 37 |
CMD ["gunicorn", "-w", "1", "-b", "0.0.0.0:7860", "--timeout", "120", "app:app"]
|