feat(docker): auto-build image before DockerRun - #437
Conversation
Extract Docker build logic into a reusable `buildDockerImage` function. Add `dockerImageExistsLocally` check to the `DockerRun` target so it automatically builds the image if not present locally, instead of failing with a missing image error.
Greptile SummaryThe PR extracts Docker image construction into a reusable function and makes
Confidence Score: 4/5The PR appears safe to merge, with a non-blocking diagnostic issue when Docker image inspection fails for reasons other than an absent image. The intended missing-image path builds and runs the image correctly, but all inspection failures currently enter that path and obscure the original Docker error. Files Needing Attention: Build.fs Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
R[DockerRun] --> E[Validate required environment variables]
E --> I[docker image inspect]
I -->|Image exists| D[docker run]
I -->|Nonzero exit| B[buildDockerImage]
B --> D
Reviews (1): Last reviewed commit: "feat(docker): auto-build image before Do..." | Re-trigger Greptile |
There was a problem hiding this comment.
Pull request overview
Updates the FAKE build script so DockerRun behaves more “out of the box” by automatically building the Docker image when it is missing locally, aligning with the usability goals described in issue #432.
Changes:
- Extracted Docker build steps into a reusable
buildDockerImagehelper. - Added a
dockerImageExistsLocallypre-check soDockerRunbuilds the image if needed. - Tightened parsing/validation of the
<Version>value read fromDirectory.Build.props.
Update `dockerImageExistsLocally` to treat only "No such image" as a missing-image case. Any other `docker image inspect` failure (for example daemon/context/permission issues) now fails fast with the Docker error output instead of being misclassified as a first-build scenario.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
Suppressed comments (1)
Build.fs:342
- The missing-image detection relies on matching a specific stderr substring ("No such image"), which is brittle across Docker versions (often "No such object") and locales. This can cause
DockerRunto fail instead of triggering a build when the image is absent. Prefer a command that reliably indicates presence without error-text parsing (e.g.,docker image ls -q <image>and check for empty stdout).
elif result.Result.Error.Contains "No such image" then
false
else
failwithf "docker image inspect failed:\n%s" result.Result.Error
Extract Docker build logic into a reusable
buildDockerImagefunction. AdddockerImageExistsLocallycheck to theDockerRuntarget so it automatically builds the image if not present locally, instead of failing with a missing image error.Addresses #432