Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +67 -27
Dockerfile
CHANGED
@@ -1,49 +1,89 @@
|
|
1 |
-
# ===== Dockerfile نهایی برای HF Spaces / Streamlit =====
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
FROM python:3.11-slim
|
3 |
|
4 |
WORKDIR /app
|
5 |
|
6 |
-
# محیطهای لازم
|
7 |
ENV HOME=/app \
|
8 |
STREAMLIT_BROWSER_GATHER_USAGE_STATS=false \
|
9 |
STREAMLIT_TELEMETRY_OPT_OUT=true
|
10 |
|
11 |
-
#
|
12 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
13 |
-
build-essential \
|
14 |
-
curl \
|
15 |
-
git \
|
16 |
-
libgl1 \
|
17 |
-
libglib2.0-0 \
|
18 |
-
tesseract-ocr \
|
19 |
-
tesseract-ocr-fas \
|
20 |
-
libtesseract-dev \
|
21 |
&& rm -rf /var/lib/apt/lists/*
|
22 |
|
23 |
-
#
|
24 |
-
RUN mkdir -p /app/.streamlit /tmp/.streamlit && \
|
25 |
-
chmod -R 777 /app/.streamlit /tmp/.streamlit
|
26 |
|
27 |
-
#
|
28 |
COPY requirements.txt ./
|
29 |
RUN python -m pip install --upgrade pip setuptools wheel && \
|
30 |
pip install --no-cache-dir -r requirements.txt
|
31 |
|
32 |
-
#
|
33 |
-
RUN printf "[server]\n\
|
34 |
-
headless = true\n\
|
35 |
-
enableXsrfProtection = false\n\
|
36 |
-
enableCORS = false\n\
|
37 |
-
maxUploadSize = 200\n\n\
|
38 |
-
[browser]\n\
|
39 |
-
gatherUsageStats = false\n" > /app/.streamlit/config.toml
|
40 |
|
41 |
-
#
|
42 |
COPY . .
|
43 |
|
44 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
EXPOSE 8501
|
46 |
HEALTHCHECK CMD curl --fail http://localhost:${PORT:-8501}/_stcore/health || exit 1
|
47 |
-
|
48 |
-
# اجرای Streamlit
|
49 |
ENTRYPOINT ["bash","-lc","streamlit run app.py --server.port=${PORT:-8501} --server.address=0.0.0.0"]
|
|
|
1 |
+
# # ===== Dockerfile نهایی برای HF Spaces / Streamlit =====
|
2 |
+
# FROM python:3.11-slim
|
3 |
+
|
4 |
+
# WORKDIR /app
|
5 |
+
|
6 |
+
# # محیطهای لازم
|
7 |
+
# ENV HOME=/app \
|
8 |
+
# STREAMLIT_BROWSER_GATHER_USAGE_STATS=false \
|
9 |
+
# STREAMLIT_TELEMETRY_OPT_OUT=true
|
10 |
+
|
11 |
+
# # دیپندنسیهای سیستمی: OpenCV + Tesseract (با فارسی) + ابزار Build
|
12 |
+
# RUN apt-get update && apt-get install -y --no-install-recommends \
|
13 |
+
# build-essential \
|
14 |
+
# curl \
|
15 |
+
# git \
|
16 |
+
# libgl1 \
|
17 |
+
# libglib2.0-0 \
|
18 |
+
# tesseract-ocr \
|
19 |
+
# tesseract-ocr-fas \
|
20 |
+
# libtesseract-dev \
|
21 |
+
# && rm -rf /var/lib/apt/lists/*
|
22 |
+
|
23 |
+
# # دایرکتوریهای قابلنوشتن برای Streamlit
|
24 |
+
# RUN mkdir -p /app/.streamlit /tmp/.streamlit && \
|
25 |
+
# chmod -R 777 /app/.streamlit /tmp/.streamlit
|
26 |
+
|
27 |
+
# # نصب پایتونپکیجها
|
28 |
+
# COPY requirements.txt ./
|
29 |
+
# RUN python -m pip install --upgrade pip setuptools wheel && \
|
30 |
+
# pip install --no-cache-dir -r requirements.txt
|
31 |
+
|
32 |
+
# # تنظیمات Streamlit: خاموش کردن XSRF/CORS و افزایش سقف آپلود
|
33 |
+
# RUN printf "[server]\n\
|
34 |
+
# headless = true\n\
|
35 |
+
# enableXsrfProtection = false\n\
|
36 |
+
# enableCORS = false\n\
|
37 |
+
# maxUploadSize = 200\n\n\
|
38 |
+
# [browser]\n\
|
39 |
+
# gatherUsageStats = false\n" > /app/.streamlit/config.toml
|
40 |
+
|
41 |
+
# # کپی کل پروژه (app.py و …)
|
42 |
+
# COPY . .
|
43 |
+
|
44 |
+
# # پورت (روی HF معمولاً PORT ست میشود؛ پیشفرض 8501)
|
45 |
+
# EXPOSE 8501
|
46 |
+
# HEALTHCHECK CMD curl --fail http://localhost:${PORT:-8501}/_stcore/health || exit 1
|
47 |
+
|
48 |
+
# # اجرای Streamlit
|
49 |
+
# ENTRYPOINT ["bash","-lc","streamlit run app.py --server.port=${PORT:-8501} --server.address=0.0.0.0"]
|
50 |
+
#########################################################################################################
|
51 |
+
|
52 |
FROM python:3.11-slim
|
53 |
|
54 |
WORKDIR /app
|
55 |
|
|
|
56 |
ENV HOME=/app \
|
57 |
STREAMLIT_BROWSER_GATHER_USAGE_STATS=false \
|
58 |
STREAMLIT_TELEMETRY_OPT_OUT=true
|
59 |
|
60 |
+
# System deps
|
61 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
62 |
+
build-essential curl git libgl1 libglib2.0-0 tesseract-ocr tesseract-ocr-fas libtesseract-dev \
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
&& rm -rf /var/lib/apt/lists/*
|
64 |
|
65 |
+
# Writable dirs
|
66 |
+
RUN mkdir -p /app/.streamlit /tmp/.streamlit /tmp/hf_home && \
|
67 |
+
chmod -R 777 /app/.streamlit /tmp/.streamlit /tmp/hf_home
|
68 |
|
69 |
+
# Python deps
|
70 |
COPY requirements.txt ./
|
71 |
RUN python -m pip install --upgrade pip setuptools wheel && \
|
72 |
pip install --no-cache-dir -r requirements.txt
|
73 |
|
74 |
+
# Streamlit config
|
75 |
+
RUN printf "[server]\nheadless=true\nenableXsrfProtection=false\nenableCORS=false\nmaxUploadSize=200\n\n[browser]\ngatherUsageStats=false\n" > /app/.streamlit/config.toml
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
|
77 |
+
# Project files
|
78 |
COPY . .
|
79 |
|
80 |
+
# ---- CONFIGURE YOUR PERSONAL MODEL HERE (choose one) ----
|
81 |
+
# (A) Local model folder baked into image (copy your folder into ./models/TrustOCR)
|
82 |
+
# ENV TRUSTOCR_PATH=/app/models/TrustOCR
|
83 |
+
# (B) Private HF repo (set token in Space Secrets or here)
|
84 |
+
# ENV TRUSTOCR_REPO=MohammadReza-Halakoo/TrustOCR
|
85 |
+
# ENV HUGGINGFACE_HUB_TOKEN=hf_xxx
|
86 |
+
|
87 |
EXPOSE 8501
|
88 |
HEALTHCHECK CMD curl --fail http://localhost:${PORT:-8501}/_stcore/health || exit 1
|
|
|
|
|
89 |
ENTRYPOINT ["bash","-lc","streamlit run app.py --server.port=${PORT:-8501} --server.address=0.0.0.0"]
|