Fastify
Deploy a Fastify HTTP service with an explicit production listener.
Deploy a Fastify API or web app.
Server entry point
This guide assumes your server starts from server.js. With TypeScript, compile first and start the compiled file.
fastify.get("/health", async () => ({ ok: true }));
await fastify.listen({
host: "0.0.0.0",
port: Number(process.env.PORT ?? 3000),
});
Set the app's health path to /health. Fastify's default logger writes to
standard output, which is what the app's Logs tab shows. Your app sits behind
Smolcloud's proxy, so if it reads the visitor's IP, set Fastify's trustProxy
option to a specific hop count or address rather than true.
Build with a Dockerfile
This Dockerfile uses npm. For pnpm, Yarn or Bun, copy that tool's lockfile instead and change the install line.
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 prune --omit=dev
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", "server.js"]
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:
smolcloud deploy APP_ID .
Open the address it prints. You can also call a route from the CLI:
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: Fastify production guidance.