Skip to content

feat: Use pre-commit cache directly from container image instead of copying #16

Description

@gerchowl

Problem

Currently, init-workspace.sh copies all template files from /root/assets/workspace/ to the user's mounted workspace, including the .pre-commit-cache directory (518MB, 22K+ files).

Copying this cache through the macOS Podman bind mount is extremely slow (60+ seconds), causing test timeouts and poor user experience.

Current Workaround

We've excluded .pre-commit-cache from the copy operation, which means:

  • Workspace init is fast (~2-3 seconds)
  • But users must wait 30-60s on first pre-commit run to rebuild the cache

Proposed Solution

The pre-commit cache is already baked into the container image at /root/assets/workspace/.pre-commit-cache. Instead of copying it, we should use it directly:

Option 1: Set PRE_COMMIT_HOME environment variable

# In docker-compose.yml
environment:
  - PRE_COMMIT_HOME=/root/assets/workspace/.pre-commit-cache

Option 2: Symlink in post-create.sh

ln -sf /root/assets/workspace/.pre-commit-cache "$HOME/.cache/pre-commit"

Benefits

  • Fast init: No 500MB copy through bind mount
  • Instant pre-commit: Cache is immediately available
  • Best of both worlds: Fast startup AND fast first pre-commit run

Related

This is part of a larger architectural discussion about moving more work inside the container (post-create.sh) rather than doing it on the host (init-workspace.sh). See discussion in PR/commits for context.

Tasks

  • Test PRE_COMMIT_HOME approach
  • Verify pre-commit hooks work correctly with shared cache
  • Update docker-compose.yml or post-create.sh
  • Remove cache exclusion workaround from init-workspace.sh (if no longer needed)
  • Update documentation

Activity

  1. c-vigo commented on Dec 18, 2025

    @c-vigo
    Contributor

    Should this be included in Release 0.2?

  2. added this to the 0.2 milestone on Dec 18, 2025
  3. gerchowl commented on Dec 18, 2025

    @gerchowl
    ContributorAuthor

    is already done. cache lives only in devcontainer under /workspace/..cache..
    never copied to host. host downloads it itself .. which is once for a repo ever .. so really not that often.
    and potentially leaving open for someone to have a common folder for his pre-commit cache

  4. added theissue type on Dec 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions