Skip to content

Conversation

@igopalakrishna
Copy link

Closes #80

This PR completely revamps the project's Docker setup to improve dependency management, build efficiency, and user experience, addressing all points outlined in the issue.

A) Dependency Management (pyproject.toml & Dockerfile)

  • Consolidated all Python package installation to use Poetry, removing the separate pip install step from the Dockerfile.
  • Moved notebook-specific packages (jupyter, ipykernel, ipython) into a new [tool.poetry.group.notebooks] group in pyproject.toml.
  • Added grpcio-tools as a development dependency to ensure reliable .proto file compilation within the Python environment.
  • Updated the protobuf version to ^4.25.0 to resolve a dependency conflict with grpcio-tools.

B) & C) Dockerfile Optimization

  • Best Practices: The Dockerfile now follows modern conventions, including:
    • Using WORKDIR instead of RUN cd.
    • Setting SHELL ["/bin/bash", "-o", "pipefail", "-c"] to ensure build steps fail correctly.
    • Using curl consistently instead of wget.
  • Build Efficiency:
    • RUN commands have been restructured into logical layers to improve Docker's layer caching and significantly speed up subsequent builds.
    • The build process now copies only pyproject.toml and poetry.lock before installing dependencies, preventing re-installation on minor code changes.
  • Simplicity:
    • The complex startup script (start.sh) and the git clone step have been removed in favor of a cleaner COPY . . and a direct CMD instruction.
    • The Jupyter token is now disabled in the CMD for a better developer experience, matching the original Dockerfile's intent.

Expanded Documentation (docs/setup/docker.md)

  • The Docker setup guide has been completely rewritten to be clearer and more comprehensive.
  • The new guide provides instructions for running the container in both foreground and detached modes.
  • It now includes specific commands for executing tasks against a running container, such as running the pytest suite or accessing an interactive shell, as requested in the issue.

How to Test

  1. Build the image: docker build -t sbsim .
  2. Run the container: docker run -p 8888:8888 sbsim
  3. Access Jupyter at http://localhost:8888.
  4. Run tests against the detached container: docker exec <container_name> poetry run pytest

Known Issue

The test suite fails with a Fatal Python error: Illegal instruction when run inside the container on an Apple Silicon (ARM) Mac. This is a known issue related to CPU instruction sets when running TensorFlow in an emulated environment and is outside the scope of the Dockerfile optimizations. The Dockerfile builds successfully, the Jupyter server runs, and the docker exec command is correctly configured for users on native x86/amd64 systems.

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.

Optimize Dockerfile

1 participant