Skip to content

Fix Docker build: Python 3.12 base image and stale poetry.lock - #13

Open
sudipdhakal1 wants to merge 1 commit into
gatewayd-io:mainfrom
sudipdhakal1:fix-docker-build
Open

sudipdhakal1 wants to merge 1 commit into
gatewayd-io:mainfrom
sudipdhakal1:fix-docker-build

Conversation

@sudipdhakal1

Copy link
Copy Markdown

Problem

docker compose up --build (and the manual docker build) currently fail out of the box. Two independent issues:

1. Python version mismatch. The base image tensorflow/tensorflow:2.16.1 ships Python 3.11, but pyproject.toml requires python = "^3.12". poetry install therefore aborts:

The currently activated Python version 3.11.0 is not supported by the project (^3.12).
Poetry was unable to find a compatible version.

2. Stale lockfile. The committed poetry.lock is out of sync with pyproject.toml, so Poetry 2.x refuses to install from it:

pyproject.toml changed significantly since poetry.lock was last generated.
Run `poetry lock` to fix the lock file.

Fix

  • Switch the base image to python:3.12-slim-bookworm (satisfying the ^3.12 constraint) and let Poetry install TensorFlow from the lockfile. Add libgomp1, which the TensorFlow CPU wheel needs at runtime.
  • Add a poetry lock step before poetry install to refresh the lockfile.

Verification

With these changes the image builds cleanly and the Prediction API serves on :8000:

$ curl 'http://localhost:8000/predict' -X POST -H 'Content-Type: application/json'     --data-raw '{"query":"SELECT * FROM users WHERE id=1 OR 1=1;"}'
{"confidence":0.0019}

Note for maintainers

The Python-version issue could alternatively be fixed by relaxing pyproject.toml to python = "^3.11" and keeping the official tensorflow/tensorflow:2.16.1 base image — a smaller diff. I went with the python:3.12 base image because it keeps the declared ^3.12 requirement intact and is the variant I built and verified end-to-end. Happy to switch to the ^3.11 approach if you prefer to stay on the TensorFlow base image.

🤖 Generated with Claude Code

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 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant