Folder-deploy context pruner silently drops directories from allowlist-style .dockerignore
Summary
When deploying a folder (openship deploy --folder) whose repo uses an allowlist-style .dockerignore (deny-all + negations), the source-tree pruner deletes directories that the .dockerignore explicitly re-includes, so the Docker build fails with missing COPY sources.
Reproduction
- Repo with this
.dockerignore:
*
!pyproject.toml
!src/
!src/**
!ops/
!ops/metabase/patch_accessibility.py- Dockerfile with
COPY src /app/haleon-src/src. openship deploy --folder --server <id>.
Observed: build context is missing src/ entirely; Docker reports:
COPY failed: file not found in build context or excluded by .dockerignore: stat src: file does not existExplicit-file re-includes (e.g. !ops/metabase/patch_accessibility.py) survive; directory re-includes do not.
Root cause
packages/adapters/src/runtime/docker-build-context.ts prunes the materialized tree with matcher.ignores(relativePath) (the npm ignore package) called on bare directory paths, then rm -rfs matches. Under gitignore semantics, the anchored /* matches the directory src, and the negation !src/ (dir-only form) does not re-match the bare path src:
ignore().add(['/*!src/','!src/**'].map(anchor)).ignores('src') // true -> pruned
ignore().add(['/*!src','!src/','!src/**'].map(anchor)).ignores('src') // false -> keptThe source comment in prepareSourceTree already anticipates this ("an allowlist root .dockerignore (* + !src) would empty the tree"), but the destructive prune still runs for root-context folder deploys.
Workaround
Add bare re-includes alongside the dir forms in .dockerignore:
!src
!opsHarmless for real Docker semantics; makes the pruner keep the directories.
Environment
- openship CLI 1.x (npm), desktop-app control plane, macOS
- Target server: Ubuntu WSL2, Docker 29 (legacy builder at the time)
- Also observed: BuildKit (
buildx) path consultscredsStorefor public base-image pulls and fails headless SSH sessions witherror getting credentials - err: exit status 1, out: A specified logon session does not exist— a missing-credsStore config should fall back to anonymous pulls.
Source: oblien/openship