File size: 2,310 Bytes
eed6dfe
 
ff17fc2
b75aa0b
eed6dfe
 
4ff5731
92f0c53
 
 
 
cf3b972
92f0c53
 
cf3b972
8fd8541
 
 
6a60d4c
 
8fd8541
 
 
 
6a60d4c
7fd5e8e
 
 
cf3b972
 
 
b75aa0b
ff17fc2
 
b8805b9
23ca858
b75aa0b
 
7a7785f
37685b8
23ca858
cf3b972
a9fec65
 
 
eed6dfe
 
ff17fc2
b75aa0b
37685b8
ff17fc2
a9fec65
 
ff17fc2
cb90bb0
 
 
 
 
b75aa0b
eed6dfe
 
b75aa0b
ff17fc2
 
eed6dfe
 
 
 
b75aa0b
cf3b972
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# Use an official Python runtime as a parent image
FROM python:3.9-slim

# Set environment variables for Python
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

# Set environment variables for Hugging Face cache to /tmp (which is writable)
ENV TRANSFORMERS_CACHE=/tmp/huggingface
ENV HF_HOME=/tmp/huggingface

# Ensure permissions are correct for /tmp/huggingface (optional, but just in case)
RUN mkdir -p /tmp/huggingface && chmod -R 777 /tmp/huggingface

# Create cache directories for Hugging Face and Matplotlib
RUN mkdir -p /app/.cache/huggingface /app/.cache/matplotlib

# Set environment variables for Hugging Face and Matplotlib cache
ENV TRANSFORMERS_CACHE=/app/.cache/huggingface
ENV HF_HOME=/app/.cache/huggingface
ENV MPLCONFIGDIR=/app/.cache/matplotlib

# Adding permission for the cache
RUN chmod -R 777 /app/.cache

# Give write permissions to the /app directory
RUN chmod -R 777 /app

# Create /app/logs directory and set permissions for logging
RUN mkdir -p /app/logs && chmod -R 777 /app/logs

# Set the working directory
WORKDIR /app

# Install system dependencies, including libgomp
RUN apt-get update && apt-get install -y \
    libgl1-mesa-glx \
    libgomp1 \
    libglib2.0-0 \
    && rm -rf /var/lib/apt/lists/*

# Set environment variables for Matplotlib and Hugging Face cache directories
ENV MPLCONFIGDIR=/tmp/matplotlib
ENV TRANSFORMERS_CACHE=/tmp/transformers_cache

# Copy the requirements file into the container at /app
COPY requirements.txt /app/

# Install any needed packages specified in requirements.txt
RUN pip install --no-cache-dir --upgrade -r requirements.txt

# Create directories for session storage, uploads, and cache
RUN mkdir -p /app/flask_sessions /app/uploads /tmp/matplotlib /tmp/transformers_cache && chmod -R 777 /app/flask_sessions /app/uploads /tmp/matplotlib /tmp/transformers_cache

#Set permission for the paddle OCR
ENV PADDLEOCR_MODEL_DIR=/tmp/.paddleocr
RUN mkdir -p /tmp/.paddleocr && chmod -R 777 /tmp/.paddleocr


# Copy the rest of the application code to /app
COPY . /app/

# Expose the port that the app runs on
EXPOSE 7860

# Set environment variables for Flask
ENV FLASK_APP=app.py
ENV FLASK_ENV=production

# Command to run the Flask app using Gunicorn
CMD ["gunicorn", "-w", "1", "-b", "0.0.0.0:7860", "--timeout", "120", "app:app"]