M
Mastra2mo ago
Karl

I need help with building mastra in Docker for Google Cloud Run

I am building a Mastra AI project, where I am also using Playwright. However, ever since the inclusion of Playwright, Mastra cannot build any longer. Mastra can build without issue on my Mac M4, but building within Docker with linux/amd64, and building on GitHub Actions yield 2 different failures.
6 Replies
Karl
KarlOP2mo ago
Local Docker shows this error.
Karl
KarlOP2mo ago
And in GitHub Action (a real x86 machine) show
STEP 14/18: RUN bun run build
$ mastra build
ERROR [2025-10-30 20:35:48.960 +0000] (Mastra CLI): Failed to analyze Mastra application: ResolveMessage: Cannot find module 'file:/app/.mastra/.build/bundler-config.mjs' from '/app/node_modules/@mastra/deployer/dist/chunk-S5UMATJZ.js'
domain: "DEPLOYER"
category: "SYSTEM"
details: ***
error: script "build" exited with code 1
Error: building at STEP "RUN bun run build": while running runtime: exit status 1
STEP 14/18: RUN bun run build
$ mastra build
ERROR [2025-10-30 20:35:48.960 +0000] (Mastra CLI): Failed to analyze Mastra application: ResolveMessage: Cannot find module 'file:/app/.mastra/.build/bundler-config.mjs' from '/app/node_modules/@mastra/deployer/dist/chunk-S5UMATJZ.js'
domain: "DEPLOYER"
category: "SYSTEM"
details: ***
error: script "build" exited with code 1
Error: building at STEP "RUN bun run build": while running runtime: exit status 1
This is my Dockerfile
FROM ubuntu
RUN apt update -y
RUN apt install -y curl unzip
RUN curl -fsSL https://bun.com/install | bash -s "bun-v1.3.1"
ENV PATH "/root/.bun/bin:$PATH"

WORKDIR /app

COPY package.json .
COPY bun.lock .
COPY tsconfig.json .
RUN bun install --frozen-lockfile

COPY . .
RUN bunx playwright install-deps
RUN bunx playwright install

RUN bun run build

ENV NODE_ENV=production
# RUN bun test
RUN bun run build

EXPOSE 4111

CMD ["bun", "run", "--import=./.mastra/output/instrumentation.mjs", ".mastra/output/index.mjs"]
FROM ubuntu
RUN apt update -y
RUN apt install -y curl unzip
RUN curl -fsSL https://bun.com/install | bash -s "bun-v1.3.1"
ENV PATH "/root/.bun/bin:$PATH"

WORKDIR /app

COPY package.json .
COPY bun.lock .
COPY tsconfig.json .
RUN bun install --frozen-lockfile

COPY . .
RUN bunx playwright install-deps
RUN bunx playwright install

RUN bun run build

ENV NODE_ENV=production
# RUN bun test
RUN bun run build

EXPOSE 4111

CMD ["bun", "run", "--import=./.mastra/output/instrumentation.mjs", ".mastra/output/index.mjs"]
I tried to use the oven/bun:1 image, but now I tried with ubuntu and manual bun installation, but it still yields the same errors. And here is my Mastra setup in "index.ts"
export const mastra = new Mastra({
bundler: {
externals: [
"playwright",
"playwright-core",
"bufferutil",
"utf-8-validate",
],
sourcemap: true,
},
workflows: { weatherWorkflow, attributeWorkflow },
agents: { weatherAgent },
scorers: {
toolCallAppropriatenessScorer,
completenessScorer,
translationScorer,
},
storage: new LibSQLStore({
// stores observability, scores, ... into memory storage, if it needs to persist, change to file:../mastra.db
url: ":memory:",
}),
logger: new PinoLogger({
name: "Mastra",
level: "info",
}),
telemetry: {
// Telemetry is deprecated and will be removed in the Nov 4th release
enabled: false,
},
observability: {
// Enables DefaultExporter and CloudExporter for AI tracing
default: { enabled: true },
},
})
export const mastra = new Mastra({
bundler: {
externals: [
"playwright",
"playwright-core",
"bufferutil",
"utf-8-validate",
],
sourcemap: true,
},
workflows: { weatherWorkflow, attributeWorkflow },
agents: { weatherAgent },
scorers: {
toolCallAppropriatenessScorer,
completenessScorer,
translationScorer,
},
storage: new LibSQLStore({
// stores observability, scores, ... into memory storage, if it needs to persist, change to file:../mastra.db
url: ":memory:",
}),
logger: new PinoLogger({
name: "Mastra",
level: "info",
}),
telemetry: {
// Telemetry is deprecated and will be removed in the Nov 4th release
enabled: false,
},
observability: {
// Enables DefaultExporter and CloudExporter for AI tracing
default: { enabled: true },
},
})
Any help is appreciated.
Mastra Triager
Mastra Triager2mo ago
GitHub
[DISCORD:1433556160891453531] I need help with building mastra in D...
This issue was created from Discord post: https://discord.com/channels/1309558646228779139/1433556160891453531 I am building a Mastra AI project, where I am also using Playwright. However, ever sin...
_roamin_
_roamin_2mo ago
Hey @Karl ! Could you try using nodejs in your docker container instead? Just to see if it builds that way.
Karl
KarlOP3w ago
Hi Romain, I had the same result with NodeJS. Anyway, I switched to Firecrawl to bypass all the runtime requirements.
_roamin_
_roamin_3w ago
Got it, thanks for getting back to me, appreciate it!

Did you find this page helpful?