Untitled
Build Context Problem
Section titled “Build Context Problem”Each actor depends on inarupa and actors_shared as path dependencies pointing outside the actor directory:
# actor mix.exsdefp deps do [ {:inarupa, path: "../../inarupa"}, {:actors_shared, path: "../actors_shared"} ]endThis works for local development — Mix resolves them from the monorepo. But Docker builds can only see files within the build context (the actor directory). The path deps don’t exist there.
Solution: Three Mix Tasks
Section titled “Solution: Three Mix Tasks”mix image.prepare — Copies inarupa and actors_shared into the actor directory using git ls-files to include only tracked files (respects .gitignore, skips _build, deps, etc.).
mix image.build [name] [tag] — Runs prepare, then docker build.
mix image.clean — Removes the copied directories.
When You Need This
Section titled “When You Need This”| Scenario | Need image.prepare? |
|---|---|
Local dev (mix test, iex -S mix) | No — path deps resolve from monorepo |
docker build locally | Yes — Docker needs files in build context |
apify push (remote build) | Yes — same Docker constraint |
| CI/CD | Yes — if building Docker images |
Dockerfile Structure
Section titled “Dockerfile Structure”The Dockerfiles expect the prepared directories at the root of the build context:
COPY actors_shared/mix.exs /app/apify_actors/actors_shared/COPY inarupa/mix.exs /app/inarupa/COPY mix.exs /app/apify_actors/<actor_name>/# deps.get, then:COPY actors_shared/lib/ /app/apify_actors/actors_shared/lib/COPY inarupa/lib/ /app/inarupa/lib/COPY lib/ /app/apify_actors/<actor_name>/lib/This layered COPY ensures Docker caching works: dependency versions change rarely, so deps.get is cached. Only lib/ changes invalidate the compile step.