Repository navigation
feat: detect dockerContextDir in apify push and refuse monorepo Actors before any write - #1502
Conversation
…as the Docker context
l2ysho
left a comment
There was a problem hiding this comment.
One suggestion, otherwise LGTM 🚀
| } | ||
| const realContextRoot = realpathSync(contextRoot); | ||
|
|
||
| const contextPathInActor = relative(realActorDir, contextRoot); |
There was a problem hiding this comment.
| const contextPathInActor = relative(realActorDir, contextRoot); | |
| const contextPathInActor = relative(realActorDir, realContextRoot); |
There was a problem hiding this comment.
Thanks! I'd keep this one as is, on purpose. This line decides whether push can simply upload the Actor folder, so it has to judge the folder the way the upload will look. Push follows a symlink and stores its files under the link's own name, so the platform only ever sees the path as written, not where the link points.
Example: the Actor folder has a symlink sym pointing to a folder outside it, and actor.json sets "dockerContextDir": "../sym". Push uploads those files as a normal folder sym inside the Actor, and the platform builds it fine. contextRoot points to sym inside the Actor, so the check says "inside", which matches. realContextRoot points to the folder outside, so the check would say "outside" and refuse a push that works today.
I added a comment on the line (50fb1b8) and a test that pins this case (1af9abf); the test fails with the suggested change.
Master's docker-context.ts (#1502) is the one implementation of dockerContextDir resolution now; runtime/source-context.ts keeps only the tarball and the upload to the runtime. Its 'outside' kind replaces the branch's 'context', readGitState replaces readGitProvenance, and the two push-monorepo test files are merged into one. Login keeps master's OAuth flow with the branch's API base URL resolution. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017ocuAJkcWwzKNChWU8WgKU
Summary
An Actor whose
.actor/actor.jsonsetsdockerContextDirabove its own folder (a monorepo Actor, as in apify/actor-monorepo-example) cannot be built from whatapify pushuploads, and--forcereplaces a working Git source with that upload.apify pushnow refuses such an Actor before any Actor read or write, pointing at the tracking Epic and the Git source workaround.Closes #1524, part of the monorepo Epic apify/apify-core#28685.
Changes
src/lib/docker-context.tswithresolveDockerContext,getContextFilePaths,readGitState, andmonorepoUnsupportedMessage, lifted from theactor-runtimebranch; the one cosmetic difference is the extractedtoPosixhelper.resolveDockerContextreports one of four kinds:none(the field is absent, with no path work),within(the context is the Actor folder or a directory inside it),outside(a monorepo Actor, with the source root and the Actor path in it), andinvalid(with the message to show).apify pushruns the resolver before the Actor lookup, the Git source prompt, and any write. It works from the Actor folder's real path, so a symlinked--dirresolves as the platform does. An invaliddockerContextDir(such as a missing directory or one outside the Git repository) exits 5, a monorepo Actor exits 255, and an absent field or a context at or below the Actor folder pushes as usual. Messages go to stderr, so--jsonkeeps stdout clean; the refusal names the folder whenactor.jsonhas no name.Tests
test/local/lib/docker-context.test.ts: the resolver inside and outside Git.test/local/lib/docker-context-files.test.ts: the file collector and its no-Git fallback.test/local/lib/docker-context-state.test.ts:readGitState.test/local/commands/push-monorepo.test.ts:apify pushon a monorepo-shaped repository with a mocked client.Notes for reviewers
actor-runtimebranch (feat: Add local Actor runtime (apify runtime) #1496) should mergemasterafterward and drop itssource-context.tsfor this module.withinrather thannone, and such a context is now checked to exist.getContextFilePathsreturns forward-slash paths on every platform.readGitStateandgetContextFilePathshave no caller yet; they land now so the upload withactorPath(apify push: upload monorepo Actors with the repository root andactorPath#1525) and the branch share one module.🤖 Generated with Claude Code