luck210 commited on
Commit
224e5e3
·
verified ·
1 Parent(s): 07335a7

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +35 -10
Dockerfile CHANGED
@@ -1,15 +1,40 @@
1
- FROM python:3.9-slim
2
 
3
- RUN useradd -m -u 1000 user
4
- USER user
5
- ENV HOME=/home/user \
6
- PATH=/home/user/.local/bin:$PATH
7
 
8
- WORKDIR /home/user/app
 
 
 
 
 
 
 
 
9
 
10
- COPY --chown=user requirements.txt requirements.txt
11
- RUN pip install --no-cache-dir --upgrade -r requirements.txt
 
12
 
13
- COPY --chown=user . /home/user/app
14
 
15
- CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.10-slim
2
 
3
+ ENV PYTHONUNBUFFERED=1
4
+ ENV TRANSFORMERS_CACHE=/app/cache
5
+ ENV UPLOAD_DIR=/app/uploads
6
+ ENV PORT=7860
7
 
8
+ # Install system dependencies
9
+ RUN apt-get update && \
10
+ apt-get install -y --no-install-recommends \
11
+ gcc \
12
+ python3-dev \
13
+ libmagic1 \
14
+ libmupdf-dev \
15
+ poppler-utils \
16
+ && rm -rf /var/lib/apt/lists/*
17
 
18
+ # Create directories and set permissions
19
+ RUN mkdir -p /app/cache /app/uploads /app/static /app/images && \
20
+ chmod -R 777 /app
21
 
22
+ WORKDIR /app
23
 
24
+ # Copy and install requirements
25
+ COPY requirements.txt .
26
+ RUN pip install --no-cache-dir -U pip setuptools wheel && \
27
+ pip install --no-cache-dir -r requirements.txt
28
+
29
+ # Copy application code
30
+ COPY . .
31
+
32
+ # Expose port
33
+ EXPOSE 7860
34
+
35
+ # Healthcheck
36
+ HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
37
+ CMD curl -f http://localhost:7860/health || exit 1
38
+
39
+ # Run the application
40
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]