# استفاده از ایمیجی که هم پایتون و هم نود جی‌اس دارد FROM nikolaik/python-nodejs:python3.10-nodejs18 WORKDIR /app # 1. نصب پکیج‌های پایتون COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # 2. ساخت فایل‌های تنظیمات برای بیلد کردن React RUN echo '{\ "name": "app",\ "version": "1.0.0",\ "type": "module",\ "scripts": {\ "build": "vite build"\ },\ "dependencies": {\ "react": "^18.2.0",\ "react-dom": "^18.2.0"\ },\ "devDependencies": {\ "@types/react": "^18.2.0",\ "@types/react-dom": "^18.2.0",\ "@vitejs/plugin-react": "^4.0.0",\ "typescript": "^5.0.0",\ "vite": "^4.4.0"\ }\ }' > package.json RUN echo 'import { defineConfig } from "vite";\ import react from "@vitejs/plugin-react";\ \ export default defineConfig({\ plugins: [react()],\ build: {\ outDir: "dist",\ emptyOutDir: true\ }\ });' > vite.config.ts RUN echo '{\ "compilerOptions": {\ "target": "ESNext",\ "lib": ["DOM", "DOM.Iterable", "ESNext"],\ "module": "ESNext",\ "skipLibCheck": true,\ "moduleResolution": "bundler",\ "allowImportingTsExtensions": true,\ "resolveJsonModule": true,\ "isolatedModules": true,\ "noEmit": true,\ "jsx": "react-jsx",\ "strict": true,\ "noUnusedLocals": false,\ "noUnusedParameters": false,\ "noFallthroughCasesInSwitch": true\ },\ "include": ["**/*.ts", "**/*.tsx"]\ }' > tsconfig.json # 3. کپی کردن فایل‌های پروژه COPY . . # 4. اصلاح index.html برای اتصال به فایل اصلی React RUN sed -i 's|||' index.html # 5. نصب و بیلد کردن پروژه RUN npm install RUN npm run build # 6. تنظیم دسترسی‌ها و پورت ENV HF_HOME=/app/.cache RUN mkdir -p $HF_HOME && chmod -R 777 $HF_HOME EXPOSE 7860 ENV GRADIO_SERVER_PORT=7860 # 7. اجرای برنامه CMD ["gunicorn", "--workers", "1", "--threads", "8", "--timeout", "120", "--keep-alive", "5", "--bind", "0.0.0.0:7860", "app:app"]