| | |
| |
|
| | |
| | FROM python:3.12.10-slim-bookworm AS base |
| |
|
| | |
| | RUN apt-get update && apt-get install --no-install-recommends -y \ |
| | curl ca-certificates && \ |
| | apt-get clean && rm -rf /var/lib/apt/lists/* ~/.cache/ |
| |
|
| | |
| | ADD https://astral.sh/uv/0.7.3/install.sh /install.sh |
| | RUN chmod -R 655 /install.sh && /install.sh && rm /install.sh |
| |
|
| | |
| | ENV PATH="/root/.local/bin:${PATH}" |
| |
|
| | |
| | WORKDIR /app |
| |
|
| | |
| | COPY pyproject.toml ./pyproject.toml |
| |
|
| | RUN uv sync --no-cache-dir --compile-bytecode \ |
| | --no-install-project --verbose |
| |
|
| | |
| | ENV PATH="/app/.venv/bin:$PATH" |
| |
|
| | |
| | RUN optimum-cli export onnx \ |
| | --opset 14 --task text-classification \ |
| | --framework pt --dtype fp32 --device cpu \ |
| | --model climatebert/distilroberta-base-climate-sentiment \ |
| | distilroberta-base-climate-sentiment-onnx |
| |
|
| | |
| | RUN optimum-cli onnxruntime quantize --avx512_vnni --per_channel \ |
| | --onnx_model distilroberta-base-climate-sentiment-onnx \ |
| | -o distilroberta-base-climate-sentiment-onnx-quantized |
| |
|
| | |
| |
|
| | |
| |
|
| | |
| | FROM python:3.12.10-slim-bookworm AS main |
| |
|
| | |
| | RUN useradd --create-home app_user |
| | USER app_user |
| |
|
| | |
| | WORKDIR /app |
| |
|
| | |
| | COPY --from=base /app/.venv ./.venv |
| | COPY --from=base /app/distilroberta-base-climate-sentiment-onnx-quantized \ |
| | ./distilroberta-base-climate-sentiment-onnx-quantized |
| |
|
| | |
| | ENV PATH="/app/.venv/bin:$PATH" |
| |
|
| | |
| | COPY main.py ./main.py |
| | COPY static ./static |
| |
|
| | |
| | EXPOSE 7860 |
| |
|
| | |
| | CMD ["uvicorn", "main:app", "--log-level", "info", "--host", "0.0.0.0" , "--port", "7860", "--workers", "1"] |
| |
|