diff --git a/.github/workflows/build-image.yml b/.github/workflows/build-image.yml index f23e4c7..960ce26 100644 --- a/.github/workflows/build-image.yml +++ b/.github/workflows/build-image.yml @@ -9,8 +9,19 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Free disk space + uses: jlumbroso/free-disk-space@main + with: + tool-cache: false + android: true + dotnet: true + haskell: true + large-packages: true + docker-images: true + swap-storage: true + - name: Build Docker image run: docker build -t image -f dockerfiles/Dockerfile . - name: Run pytest on image - run: docker run image poetry run pytest + run: docker run image pytest diff --git a/dockerfiles/Dockerfile b/dockerfiles/Dockerfile index 897c66f..6d2b231 100644 --- a/dockerfiles/Dockerfile +++ b/dockerfiles/Dockerfile @@ -4,17 +4,16 @@ FROM python:3.13-slim # Set the working directory in the container WORKDIR /app -# Install poetry -RUN pip install --no-cache-dir poetry poetry-plugin-export - # Copy the dependency files to the working directory COPY pyproject.toml poetry.lock ./ -# Using poetry to make a requirements.txt then pip to do the install. -# Pip is aggressive with storage space. -RUN poetry export -f requirements.txt -o requirements.txt --without-hashes --with dev - -RUN pip install --no-cache-dir -r requirements.txt \ +# Install poetry, export requirements, install deps with CPU-only PyTorch, +# then clean up poetry -- all in one layer to minimize image size. +RUN pip install --no-cache-dir poetry poetry-plugin-export \ + && poetry export -f requirements.txt -o requirements.txt --without-hashes --with dev \ + && pip install --no-cache-dir -r requirements.txt \ + --extra-index-url https://download.pytorch.org/whl/cpu \ + && pip uninstall -y poetry poetry-plugin-export \ && rm requirements.txt # Copy the rest of the application code to the working directory