How can I deploy agent Dockerfile from apps/agent ...
# ask-ai
c
How can I deploy agent Dockerfile from apps/agent subdirectory in Node.js monorepo?
t
Thanks for reaching out, Rin. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
You can deploy the agent Dockerfile from the
apps/agent
subdirectory by telling the LiveKit CLI to use that directory as the build context. 1. From the monorepo root, deploy an existing agent:
Copy code
lk agent deploy apps/agent
1. If the agent hasn’t been created yet:
Copy code
lk agent create apps/agent --region <your-region>
Notes to ensure a successful deploy: •
apps/agent
should contain the
Dockerfile
and
livekit.toml
(or pass
--config
to point to a different config). • Provide required secrets (for example
OPENAI_API_KEY
) via
--secrets
,
--secrets-file
, or in
livekit.toml
. • Ensure your
Dockerfile
is configured for your Node.js setup (base image, package manager like
pnpm
if used). Would you like the exact command including secrets or an example
livekit.toml
for a Node.js agent? Sources: Agent deployment CLI reference | LiveKit docs | Builds and Dockerfiles | LiveKit Docs
c
That apps/agent has dependencies from the same repository (packages/*)
t
You're on the right track — your agent can use packages from the same repo, but the Docker build must have access to those packages and use a workspace-aware installer. Quick steps to do this: 1. From monorepo root, build using the agent Dockerfile so
packages/*
are in build context:
Copy code
docker build -f apps/agent/Dockerfile .
Or with LiveKit CLI:
Copy code
lk agent deploy apps/agent
(Deploy will use the specified directory as build context.) 1. Use a workspace-aware package manager (pnpm, yarn/npm workspaces). Example pnpm setup: • Root:
pnpm-workspace.yaml
includes
packages/*
and
apps/agent
. • In
apps/agent/package.json
depend on local packages with
workspace:*
. 1. Adjust Dockerfile to copy root manifests, workspace config, packages, then install: • COPY root files:
package.json
,
pnpm-lock.yaml
,
pnpm-workspace.yaml
. • COPY
packages
and
apps/agent
into image. • RUN
pnpm install --frozen-lockfile
• WORKDIR
/app/apps/agent
then RUN
pnpm build
and CMD to start. Minimal example:
Copy code
FROM node:22-slim
WORKDIR /app
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
COPY packages ./packages
COPY apps/agent ./apps/agent
RUN corepack enable && corepack prepare pnpm@latest --activate
RUN pnpm install --frozen-lockfile
WORKDIR /app/apps/agent
RUN pnpm build
CMD ["pnpm","start"]
1. Important notes • Run builds from repo root (so
packages/
are in context). • Do not .dockerignore the needed
packages/
. • Provide secrets via
--secrets
,
--secrets-file
, or
livekit.toml
when deploying with
lk
. • Optimize by copying only package manifests for caching if you have many files. Would you like a tailored Dockerfile using your repo structure or an example
livekit.toml
? Sources: Builds and Dockerfiles | LiveKit Docs