Docker
View as MarkdownYou can containerize your Neutron application with the docker preset, or with the Node.js adapter and a Dockerfile of your own.
--preset docker
neutron-ts build --preset docker
docker build -t my-neutron-app dist
docker run -p 3000:3000 my-neutron-app
The build writes a complete image context into dist/: server.mjs, a Dockerfile and .dockerignore, the runtime bundle under dist/server/node/, and the bundle's runtime dependencies under dist/node_modules/. The bundle keeps @neutron-build/core's own dependencies external, as the neutron-ts start bundle does. Everything it imports at runtime is copied into the context as real directories (symlinks dereferenced), together with each package's production dependencies, so the image needs no npm install and works from a pnpm workspace, including with resolve.preserveSymlinks. Build the image from dist/ itself; nothing outside it is read.
Dockerfile
Create a Dockerfile in your project root:
# 1. Build Stage
FROM node:20-alpine AS builder
WORKDIR /app
COPY package.json pnpm-lock.yaml ./
RUN npm install -g pnpm && pnpm install --frozen-lockfile
COPY . .
RUN pnpm run build
# 2. Production Stage
FROM node:20-alpine AS runner
WORKDIR /app
ENV NODE_ENV=production
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/package.json ./package.json
COPY --from=builder /app/node_modules ./node_modules
EXPOSE 3000
CMD ["node", "dist/server/index.js"]
Build and Run
docker build -t my-neutron-app .
docker run -p 3000:3000 my-neutron-app