From 38a78912c65d895c0b93ebc25e7c334cdc895716 Mon Sep 17 00:00:00 2001 From: sudipdhakal1 Date: Sat, 26 Sep 2026 16:21:22 -0400 Subject: [PATCH] Fix Docker build: Python 3.12 base image and stale poetry.lock The image failed to build for two reasons: 1. The base image `tensorflow/tensorflow:2.16.1` ships Python 3.11, but `pyproject.toml` requires `python = "^3.12"`, so `poetry install` aborted with "Poetry was unable to find a compatible version." Switch to `python:3.12-slim-bookworm` (adding `libgomp1`, which the TensorFlow CPU wheel needs at runtime) and let Poetry install TensorFlow from the lockfile. 2. The committed `poetry.lock` is out of sync with `pyproject.toml`, so Poetry 2.x refuses with "pyproject.toml changed significantly since poetry.lock was last generated." Add a `poetry lock` step before `poetry install` to refresh it. With these changes `docker compose up --build` builds cleanly and the Prediction API serves requests on :8000. Co-Authored-By: Claude Opus 4.8 --- Dockerfile | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 185b419..0078a90 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,12 @@ -FROM tensorflow/tensorflow:2.16.1 +# NOTE: upstream used tensorflow/tensorflow:2.16.1, which ships Python 3.11 and +# is rejected by pyproject.toml's `python = "^3.12"` constraint. Build on a +# Python 3.12 base instead and let Poetry install TensorFlow from poetry.lock. +FROM python:3.12-slim-bookworm + +# libgomp1 is required at runtime by the TensorFlow CPU wheel. +RUN apt-get update \ + && apt-get install -y --no-install-recommends libgomp1 \ + && rm -rf /var/lib/apt/lists/* ENV KMP_AFFINITY=noverbose ENV TF_CPP_MIN_LOG_LEVEL=3 @@ -16,6 +24,8 @@ COPY training/sql_tokenizer.py /app/ COPY training/sql_tokenizer_vocab.json /app/ COPY sqli_model/3/ /app/sqli_model/3/ RUN pip install --disable-pip-version-check poetry +# Committed poetry.lock is out of sync with pyproject.toml; refresh it, then install. +RUN poetry lock RUN poetry install --no-root EXPOSE 8000