Skip to content

mpm compose up --watch: Docker build cache not invalidated on source changes #66

Description

@firstdorsal

Problem

mpm compose up --watch correctly detects source file changes in build context directories and re-triggers the deploy cycle, but Docker's build layer cache is not invalidated. The container keeps running with old code.

Root Cause

In utils/mows-cli/src/package_manager/compose/docker.rs, compose_up passes --build but never --no-cache:

cmd.arg("up");
if options.build {
    cmd.arg("--build");
}

--build alone relies on Docker's BuildKit layer cache. When COPY src src encounters the same content hash (stale cache), it skips rebuilding even though files changed.

Expected Behavior

When --watch detects changes in a build context directory, the subsequent rebuild should pick up the new source files.

Suggested Fix

When the watch detects a change in a build context directory (as extracted by extract_build_contexts), pass --no-cache for that specific service's rebuild. This avoids unnecessarily rebuilding all services while ensuring changed contexts are rebuilt fresh.

Alternatively, a simpler approach: always pass --no-cache during watch-triggered rebuilds (not on the initial deploy).

Reproduction

  1. mpm compose up --watch on a project with a Rust API build context
  2. Modify a source file in the build context
  3. Watch triggers a re-deploy, but the container runs old code
  4. docker compose build --no-cache api followed by mpm compose up correctly picks up changes

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions