RaIDeNz/api-ocr-test1
0
1FROM python:3.11-slim2 3ENV PYTHONUNBUFFERED=1 \4 PIP_NO_CACHE_DIR=1 \5 HOME=/tmp \6 XDG_CACHE_HOME=/tmp/.cache \7 SELENIUM_MANAGER_CACHE_DIR=/tmp/selenium \8 TMPDIR=/tmp \9 CHROME_BINARY=/usr/bin/chromium \10 CHROMEDRIVER=/usr/bin/chromedriver \11 CHROME_EXTRA_ARGS="--no-sandbox --disable-dev-shm-usage --disable-gpu --window-size=1920,1080 --headless=new"12 13RUN apt-get update && \14 apt-get install -y --no-install-recommends \15 chromium chromium-driver \16 fonts-liberation \17 libgbm1 libnss3 libxss1 libasound2 libxshmfence1 \18 ca-certificates && \19 rm -rf /var/lib/apt/lists/*20 21RUN mkdir -p /app/downloaded_files /tmp/.cache /tmp/selenium && \22 chmod -R 777 /app/downloaded_files /tmp/.cache /tmp/selenium23 24COPY requirements.txt .25RUN pip install --no-cache-dir -r requirements.txt26 27RUN python -c "import os, sysconfig, pathlib; site=pathlib.Path(sysconfig.get_paths()['purelib']); p=site/'seleniumbase'/'drivers'; print('Fixing perms under:', p); p.mkdir(parents=True, exist_ok=True); os.system(f'chmod -R a+rwX {p}')"28 29RUN chmod a+rx /usr/bin/chromium /usr/bin/chromedriver30 31WORKDIR /app32COPY . /app33 34CMD ["gunicorn","-w","1","--threads","1","-k","uvicorn.workers.UvicornWorker","--bind","0.0.0.0:8080","app.main:app"]35 