VitePress
nginx runtime image for serving a built VitePress site, on nginx 1.30 Alpine.
registry.gitlab.com/hosstio/docker-images/vitepress/main:latestSource: hosstio/docker-images/vitepress
Features
- Clean URLs, matching VitePress
cleanUrls: true(/getting-startedservesgetting-started.html) - Redirects the
.htmlforms to their clean equivalents, so every page has one URL - Serves VitePress's own
404.htmlwith a 404 status - Caches the fingerprinted
assets/for a year (immutable) and makes browsers revalidate every page (no-cache) - Gzip for HTML, plain text, CSS, JavaScript, JSON, SVG, XML and RSS responses of 1 KB and up
The image contains no Node.js and builds nothing. Each project keeps its own build stage, because the build needs that project's package.json and content.
Usage
Build the site in a Node stage, then copy the output into this image:
dockerfile
FROM node:24-slim AS build
WORKDIR /app
# VitePress reads git history for lastUpdated
# hadolint ignore=DL3008
RUN apt-get update \
&& apt-get install --yes --no-install-recommends git \
&& rm --recursive --force /var/lib/apt/lists/*
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run docs:build
FROM registry.gitlab.com/hosstio/docker-images/vitepress/main:latest AS runtime
COPY --from=build /app/docs/.vitepress/dist /usr/share/nginx/htmlNo CMD is needed: the nginx base image's CMD starts nginx in the foreground.
Overriding the configuration
The site config lives at /etc/nginx/conf.d/default.conf. A project that needs its own redirects or short links replaces it:
dockerfile
COPY docs/nginx.conf /etc/nginx/conf.d/default.conf