-
Notifications
You must be signed in to change notification settings - Fork 54
fix(ci): fix the monorepo #299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
e692213
250178a
9accd17
c3f6fce
719da43
bbb7464
968ca46
027ea86
c1046bd
21d66fc
cc0d075
8e88775
9d914a0
5a802cb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| # Actor images build from the monorepo root (dockerContextDir in .actor/actor.json). | ||
| # Keep the context lean: ship sources + manifests + the pnpm lockfile only. | ||
| node_modules | ||
| **/node_modules | ||
| .git | ||
| .turbo | ||
| **/dist | ||
| **/storage | ||
| apify_storage | ||
| crawlee_storage | ||
| *.log | ||
| .DS_Store | ||
| .idea | ||
| .vscode |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,8 @@ | |
| "name": "camoufox-scraper", | ||
| "version": "0.1", | ||
| "buildTag": "latest", | ||
| "dockerContextDir": "../../../..", | ||
| "dockerfile": "../Dockerfile", | ||
|
Comment on lines
+6
to
+7
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same in every actor points the Docker build context at the monorepo root so the build can use the root pnpm-lock.yaml for a frozen, deterministic install. apify push of a single folder can't do this (no root lockfile in the upload). that's why builds run from the Git source. inspired by actor-monorepo-example |
||
| "storages": { | ||
| "dataset": { | ||
| "actorSpecification": 1, | ||
|
|
||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,31 +1,45 @@ | ||
| FROM apify/actor-node-playwright-camoufox:22 AS builder | ||
| # Build context is the monorepo root (dockerContextDir in .actor/actor.json), so the build uses the | ||
| # root pnpm-lock.yaml for a deterministic install. | ||
| # | ||
| # The base is pinned by digest (reproducible Camoufox binary + OS deps). The actor pins playwright and | ||
| # camoufox-js to the versions this base ships (24-1.59.1 -> playwright 1.59.1, camoufox-js 0.11.1) and | ||
| # bundles them, so the bundled drivers match the Camoufox binary they drive. The binary itself lives in | ||
| # ~/.cache/camoufox (outside node_modules) and stays in the base. Tag 24-1.59.1 is the newest Camoufox | ||
| # base that survives page JS errors (24-1.60.0 crashes the process on them). | ||
| FROM apify/actor-node-playwright-camoufox:24-1.59.1@sha256:eadc96fa9492284eb45ef70b6b91c841fae7f142d25a22ae2887a21bb78b3469 AS builder | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same for each browser. Base is pinned by sha256 digest, not just a tag, on purpose: tags are mutable, so a bare tag wouldn't give a reproducible browser binary. Since the whole runtime browser stack comes from the base (see the driver note), the digest is what actually makes the browser deterministic. Renovate bumps the digest. Also, not the newest base. I've tested the latest camoufox base (24-1.60.0, Camoufox 150): it crashes the whole process on any page that emits a JS error (playwright's Firefox pageError handler). I also tried the latest Playwright (1.61.x), which won't even launch this Camoufox binary (Browser.setDefaultViewport protocol error). 24-1.59.1 is the newest camoufox base that survives page errors. |
||
|
|
||
| COPY --chown=myuser package*.json ./ | ||
| # The browser base runs as `myuser`; the build stage needs root for corepack + a writable workdir. | ||
| USER root | ||
| WORKDIR /app | ||
|
|
||
| RUN npm install --include=dev --audit=false | ||
| RUN corepack enable | ||
|
|
||
| COPY --chown=myuser . ./ | ||
| # Browsers ship with the base image; never let an npm postinstall download them. | ||
| ENV PUPPETEER_SKIP_DOWNLOAD=true \ | ||
| PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 | ||
|
|
||
| RUN npm run build | ||
| # Whole workspace (root .dockerignore keeps node_modules/.git/dist out of the context). | ||
| COPY . ./ | ||
|
|
||
| FROM apify/actor-node-playwright-camoufox:22 | ||
| # Deterministic install (frozen lockfile, honors minimumReleaseAge) of the actor + its workspace deps. | ||
| RUN pnpm install --frozen-lockfile --filter actor-camoufox-scraper... | ||
|
|
||
| COPY --from=builder --chown=myuser /home/myuser/dist ./dist | ||
| # Build the actor and its workspace dependency @apify/scraper-tools. | ||
| RUN pnpm --filter actor-camoufox-scraper... build | ||
|
|
||
| COPY --chown=myuser package*.json ./ | ||
| # Self-contained production bundle; inject-workspace-packages copies the built @apify/scraper-tools | ||
| # into node_modules instead of symlinking it. The native better-sqlite3 binding (a camoufox-js dep) is | ||
| # compiled here against the base's Node 24, and the runtime stage uses that same base, so it matches. | ||
| RUN pnpm --config.inject-workspace-packages=true --filter actor-camoufox-scraper deploy --prod /deploy | ||
|
|
||
| RUN npm --quiet set progress=false \ | ||
| && npm install --omit=dev \ | ||
| && echo "Installed NPM packages:" \ | ||
| && (npm list --omit=dev --all || true) \ | ||
| && echo "Node.js version:" \ | ||
| && node --version \ | ||
| && echo "NPM version:" \ | ||
| && npm --version \ | ||
| && rm -r ~/.npm | ||
| FROM apify/actor-node-playwright-camoufox:24-1.59.1@sha256:eadc96fa9492284eb45ef70b6b91c841fae7f142d25a22ae2887a21bb78b3469 | ||
|
|
||
| COPY --chown=myuser . ./ | ||
| # Base WORKDIR is /home/myuser and ships the Xvfb entrypoint plus the Camoufox binary in | ||
| # ~/.cache/camoufox (outside node_modules). Replace only the template node_modules with the lean | ||
| # production bundle (which carries the matching playwright + camoufox-js); the binary stays in the base. | ||
| RUN rm -rf node_modules | ||
| COPY --from=builder --chown=myuser /deploy ./ | ||
|
|
||
| ENV APIFY_DISABLE_OUTDATED_WARNING=1 | ||
|
|
||
| CMD ./start_xvfb_and_run_cmd.sh && npm run start:prod --silent | ||
| CMD ["node", "dist/main.js"] | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this won't fix the timeouting e2e tests. Likely caused by microsoft/playwright#40724 (bumping Playwright or reverting Node version might help)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's not the fix 😄, it's just for the future (if something happens then fail is better than getting stuck) The actual fix is browser-install step