Skip to content
For agents
Browse guides

Static sites

Serve plain HTML or a built React, Vue or Angular frontend.

Open Markdown

Deploy the HTML, CSS and JavaScript produced by your frontend build. The container serves those files; API routes and server-side rendering need a server app instead.

Build output

React and Vue projects built with Vite usually write to dist after vite build. Astro static sites also use dist. For Angular, check your build output and change the Dockerfile's copy path; it is commonly dist/PROJECT/browser.

If your Next.js, Nuxt, SvelteKit or TanStack Start app has server routes, use that framework's guide instead. Copying only its static files leaves the server code behind.

Build with a Dockerfile

Commit package-lock.json. This Dockerfile builds the site, then serves it with Caddy on port 3000.

Code
FROM node:24.21.0-bookworm-slim AS build
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
COPY . .
RUN npm run build
FROM caddy:2-alpine
COPY --from=build /app/dist /srv
COPY Caddyfile /etc/caddy/Caddyfile
USER 10001:10001
EXPOSE 3000
CMD ["caddy", "run", "--config", "/etc/caddy/Caddyfile", "--adapter", "caddyfile"]

Caddyfile

Code
{
  admin off
  auto_https off
}
:3000 {
  root * /srv
  handle /health {
    respond "ok" 200
  }
  handle {
    try_files {path} /index.html
    file_server
  }
}

Set the app's health path to /health.

The try_files line sends unknown paths to index.html, which single-page apps need for client-side routing. For a content site where a missing page should return 404, remove it.

Environment variables in a static site are baked in at build time and visible to everyone. For anything secret, or to reach a database, call a backend app.

You may not need a Dockerfile at all: Smolcloud detects most static projects and builds them itself. Use this one when the automatic build picks the wrong output folder.

Deploy and check

Add a .dockerignore that excludes .env*, .git, node_modules and your local build output, then deploy:

Shell
smolcloud deploy APP_ID .

Open a page deep in the site, such as /settings/profile, and refresh it. It should load, with its styles and images. Then try an address that doesn't exist and check you get what you expect.

See also Vite's deployment guide and Automatic builds.