Spaces:
Running on Zero
Running on Zero
| # lightweight Python 3.11 base image | |
| FROM python:3.11-slim | |
| # prevent .pyc files, enable real-time logs, disable pip cache, and set app port | |
| ENV PYTHONDONTWRITEBYTECODE=1 \ | |
| PYTHONUNBUFFERED=1 \ | |
| PIP_NO_CACHE_DIR=1 \ | |
| PORT=7860 | |
| # set the container working directory | |
| WORKDIR /app | |
| # install system packages and remove package cache | |
| RUN apt-get update \ | |
| && apt-get install -y --no-install-recommends libgomp1 curl \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # copy dependency definitions into the container | |
| COPY requirements.txt . | |
| # upgrade pip and install Python dependencies | |
| RUN pip install --upgrade pip && pip install -r requirements.txt | |
| # copy the application source code | |
| COPY . . | |
| # document the port used by the application | |
| EXPOSE 7860 | |
| # check that the application is responding correctly | |
| HEALTHCHECK --interval=30s --timeout=5s --start-period=90s --retries=3 \ | |
| CMD curl -fsS http://localhost:7860/ >/dev/null || exit 1 | |
| # start app | |
| CMD ["python", "app.py"] |