Skip to content

Conversation

@Darktex
Copy link
Contributor

@Darktex Darktex commented Jan 27, 2026

Summary

  • Fixed multi-stage Docker build to copy pip-installed console scripts (uvicorn, fastapi) from builder stage
  • Added tests to verify console script availability in the base image

Fixes #244

Test plan

  • Lint check passes
  • All tests pass (344 passed, 45 skipped)
  • Build openenv-base image: docker build -t openenv-base:latest -f src/openenv/core/containers/images/Dockerfile .
  • Verify uvicorn command: docker run --rm openenv-base:latest uvicorn --version
  • Verify fastapi command: docker run --rm openenv-base:latest fastapi --help

The multi-stage Docker build was copying Python packages but not the
console scripts installed by pip in /usr/local/bin/. This meant `uvicorn`
and `fastapi` commands were unavailable, though `python -m uvicorn` worked.

Added COPY directive to transfer console scripts from builder stage.
@meta-cla meta-cla bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jan 27, 2026
@greptile-apps
Copy link

greptile-apps bot commented Jan 27, 2026

Greptile Overview

Greptile Summary

This PR fixes a critical bug in the multi-stage Docker build for the openenv-base image where console scripts (uvicorn, fastapi) installed by pip were not available in the final image.

Changes Made:

  • Added COPY --from=builder /usr/local/bin/uvicorn /usr/local/bin/fastapi /usr/local/bin/ to the Dockerfile to copy pip-installed console scripts from the builder stage
  • Created comprehensive test suite (tests/test_core/test_docker_base_image.py) with 5 tests to verify console scripts and Python module imports work correctly

Impact:

  • Fixes issue openenv-base image has no uvicorn command #244 where environments couldn't start because uvicorn command was missing
  • Ensures all pip-installed console scripts are available in the runtime image
  • Tests validate both command availability and Python module imports

Testing:

  • New tests use @pytest.mark.docker and gracefully skip if Docker is unavailable
  • Tests verify uvicorn --version, fastapi --help, and Python imports work correctly
  • Proper fixtures ensure Docker daemon is running and image exists before testing

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk - it's a straightforward bug fix with comprehensive tests
  • The fix is minimal (3 lines), well-understood (copies missing binaries), and thoroughly tested with 5 new test cases that validate the fix works correctly
  • No files require special attention - both changes are straightforward and well-tested

Important Files Changed

Filename Overview
src/openenv/core/containers/images/Dockerfile Adds console script copying to fix missing uvicorn/fastapi commands in multi-stage build
tests/test_core/test_docker_base_image.py New test file with comprehensive Docker image validation for console scripts availability

Sequence Diagram

sequenceDiagram
    participant Dev as Developer
    participant Docker as Docker Build
    participant Builder as Builder Stage
    participant Final as Final Stage
    participant Image as openenv-base Image

    Dev->>Docker: docker build -t openenv-base:latest
    Docker->>Builder: FROM uv:0.5.27-python3.11
    Builder->>Builder: COPY pyproject.toml, uv.lock
    Builder->>Builder: RUN uv pip install --system
    Note over Builder: Installs packages to<br/>/usr/local/lib/python3.11/site-packages<br/>and console scripts to /usr/local/bin/
    
    Docker->>Final: FROM python:3.11-slim
    Final->>Builder: COPY uv, uvx binaries
    Final->>Builder: COPY site-packages/
    Final->>Builder: COPY uvicorn, fastapi binaries
    Note over Final: NEW: Copies console scripts<br/>from builder stage
    
    Final->>Image: Build complete
    Image-->>Dev: openenv-base:latest ready
    
    Dev->>Image: docker run uvicorn --version
    Image-->>Dev: ✓ uvicorn command works
Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

openenv-base image has no uvicorn command

2 participants