Skip to content
KeystoneJS LogoKeystoneJS


Keystone files need to be built with keystone build before running in production mode.

Keystone can be easily built as a Docker container image, suitable for deploying on Kubernetes or other environments.

Recommended guides:

You'll need to add a .dockerignore file to the root of your Keystone project (or wherever the image is built from) to avoid including unwanted files in the image. Here's an example of what it might look like:


If you're already familiar with Heroku or Pivotal Cloudfoundry, you might find Cloud Native Buildpacks a simple way to build Docker images.

The following is an example of production-ready Dockerfile for a Keystone app built with yarn build and started with yarn start:


# Build container
FROM node:${NODE_VERSION}-alpine AS build

WORKDIR /home/node

RUN apk add --no-cache build-base python2 yarn && \
    wget -O dumb-init -q${DUMB_INIT_VERSION}/dumb-init_${DUMB_INIT_VERSION}_amd64 && \
    chmod +x dumb-init
ADD . /home/node
RUN yarn install && yarn build && yarn cache clean

# Runtime container
FROM node:${NODE_VERSION}-alpine

WORKDIR /home/node

COPY --from=build /home/node /home/node

CMD ["./dumb-init", "yarn", "start"]

When using Docker for deployment, you'll also need a registry to serve your images. This can be the official Docker Hub, a registry in your cloud provider, a third-party hosted registry, or a self-hosted private registry.

If you have .dockerignore and Dockerfile files in the root of your Keystone project, and you're set up with a registry, you can build and push your image like this:

# Build on local machine
docker build -t .
# Push to registry server
docker push

You can test running your image locally (no need to push) with a command like this (assuming your server runs on port 3000):

docker run --rm -p

On this page

    Edit on GitHub