Skip to content
For agents
Browse guides

Astro

Choose static output for content sites or the Node adapter for server rendering.

Open Markdown

Deploy an Astro site as static files, or as a Node server when it renders pages on request.

Choose static or server output

For a content site with no server routes, publish dist using the static-site guide.

For server-rendered pages, install @astrojs/node. Set output: "server" and adapter: node({ mode: "standalone" }) in astro.config.mjs. Run astro build, then start node dist/server/entry.mjs.

The image needs both dist/client and dist/server, plus node_modules. Add a /health route returning 200 and set it as the app's health path. Read secrets only in server code.

Build with a Dockerfile

This Dockerfile uses npm. For pnpm, Yarn or Bun, copy that tool's lockfile instead and change the install line.

Code
FROM node:24.21.0-bookworm-slim@sha256:d6aa754f16b3197301076f047b5def2f02ea1dbbc2ca920407d46d7ec7f87b20 AS build
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
COPY . .
RUN npm run build

FROM node:24.21.0-bookworm-slim@sha256:d6aa754f16b3197301076f047b5def2f02ea1dbbc2ca920407d46d7ec7f87b20
WORKDIR /app
ENV NODE_ENV=production HOST=0.0.0.0 PORT=3000
COPY --from=build --chown=10001:10001 /app ./
USER 10001:10001
EXPOSE 3000
CMD ["node", "dist/server/entry.mjs"]

Deploy the app

Save the Dockerfile at the source root. In Configuration, set the port to 3000 and the health path to the route you added above. Add a .dockerignore that excludes .env*, .git, node_modules and local build output, then deploy:

Shell
smolcloud deploy APP_ID .

Open the address it prints. You can also call a route from the CLI:

Shell
smolcloud request APP_ID /

You don't have to write a Dockerfile: see Automatic builds. To add a database or file storage, see Databases and files.

See also: Astro Node adapter.