numerous-whale-53652
08/25/2025, 7:24 PMtall-airline-16756
08/25/2025, 7:24 PMtall-airline-16756
08/25/2025, 7:26 PM# Dockerfile for LiveKit agent-starter-react (Next.js application)
# syntax=docker/dockerfile:1
# Use Node.js 22 slim base image
ARG NODE_VERSION=22
FROM node:${NODE_VERSION}-slim AS base
# Configure pnpm installation directory and ensure it is on PATH
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
# Install required system packages and pnpm
RUN apt-get update -qq && apt-get install --no-install-recommends -y ca-certificates && rm -rf /var/lib/apt/lists/*
RUN npm install -g pnpm@9.7.0
# Set working directory
WORKDIR /app
# Build stage
FROM base AS build
# Copy dependency files first for better layer caching
COPY package.json pnpm-lock.yaml ./
# Install dependencies using frozen lockfile for reproducible builds
RUN pnpm install --frozen-lockfile
# Copy all application files
COPY . .
# Build the Next.js application
RUN pnpm run build
# Remove development dependencies to reduce runtime image size
RUN pnpm prune --prod
# Runtime stage
FROM base AS runtime
# Create a non-privileged user for security
ARG UID=10001
RUN adduser \
--disabled-password \
--gecos "" \
--home "/app" \
--shell "/sbin/nologin" \
--uid "${UID}" \
appuser
# Copy built application and production dependencies from build stage
COPY --from=build /app /app
COPY --from=build /etc/ssl/certs /etc/ssl/certs
# Ensure proper ownership and switch to non-privileged user
RUN chown -R appuser:appuser /app
USER appuser
# Set Node.js to production mode
ENV NODE_ENV=production
# Expose Next.js default port
EXPOSE 3000
# Start the Next.js application
CMD ["pnpm", "start"]
To get this up and running, just build and run the container like this:
# Build the image
docker build -t agent-starter-react .
# Run the container
docker run -p 3000:3000 \
-e LIVEKIT_API_KEY=your_api_key \
-e LIVEKIT_API_SECRET=your_api_secret \
-e LIVEKIT_URL=<YOUR_LIVEKIT_SERVER_URL> \
agent-starter-react
If you hit any bumps or want to chat more about it, just let me know—I’m here to help!
Sources: pkg/agentfs/examples/node.Dockerfile | pnpm-lock.yaml | Infrastructure & Deployment | livekit/livekit_composite | DeepWiki