dottxt-ai / outlines

Structured Text Generation
https://dottxt-ai.github.io/outlines/
Apache License 2.0
9.57k stars 492 forks source link

Adding “outlines” as a dependency drastically increases Docker image size by ~10GB. #1215

Open quasinnovate opened 1 month ago

quasinnovate commented 1 month ago

Describe the issue as clearly as possible:

When adding “outlines” as a dependency to a Python project managed with Poetry, the Docker image size increases by approximately 10GB. This issue occurs even with a simple or dummy project setup. The initial image size without “outlines” is significantly smaller, making this behavior unexpected and problematic for production environments where lean images are desired.

Steps/code to reproduce the bug:

1.  Create a Python project using Poetry without the “outlines” dependency.
    2.  Build the Docker image for the project and note the image size.
    3.  Add “outlines” as a dependency to the project via Poetry.
    4.  Rebuild the Docker image and check the size again.

# Step 1: Create a new project
poetry new project1
cd project1

# Step 2: Build the initial Docker image
docker build -t project1-image .

Dockerfile for Project 1 (Without Outlines):

# Project 1 Dockerfile
FROM python:3.9-slim

# Install Poetry
RUN pip install poetry

# Set working directory
WORKDIR /app

# Copy the pyproject.toml and poetry.lock files
COPY pyproject.toml poetry.lock /app/

# Install dependencies
RUN poetry install --no-root

# Copy the source code
COPY . /app/

# Run the application (adjust to the actual entrypoint or command of your project)
CMD ["poetry", "run", "python", "-m", "project1"]

Commands for Project 2 (With Outlines):

# Step 3: Add the "outlines" dependency
poetry add outlines

# Step 4: Build the Docker image with outlines included
docker build -t project2-image .

Dockerfile for Project 2 (With Outlines):

# Project 2 Dockerfile
FROM python:3.9-slim

# Install Poetry
RUN pip install poetry

# Set working directory
WORKDIR /app

# Copy the pyproject.toml and poetry.lock files
COPY pyproject.toml poetry.lock /app/

# Install dependencies (including outlines)
RUN poetry install --no-root

# Copy the source code
COPY . /app/

# Run the application (adjust to the actual entrypoint or command of your project)
CMD ["poetry", "run", "python", "-m", "project2"]

### Expected result:

```shell
### Expected Result:

Adding the “outlines” dependency should not result in a significant increase in Docker image size.

Actual Result:

After adding the “outlines” dependency, the Docker image size increases by over 10GB, suggesting an issue with the dependency or related dependencies dramatically bloating the image.

Error message:

No response

Outlines/Python version information:

Version information

``` (command output here) ```

Context for the issue:

Suggestion for improvement and efficiency.

great library, BTW!