Docker

In general, a Vike app is just a Node.js server, so we can use any Node.js Docker container.

Build

If we build our app in Docker, we may stumble upon out-of-memory errors.

If we do, we check whether our Docker container has enough memory, and we may also need to set Node.js' --max-old-space-size.

// package.json
{
  "scripts": {
    "// We use Node.js' environment variable `NODE_OPTIONS` to increase memory size to 3GB": "",
    "build": "NODE_OPTIONS=--max-old-space-size=3072 npm run build:run",
    "build:run": "vite build"
  }
}

See also:

Dev

If we want to use Docker for development as well, we need to properly configure Docker for Vite's HMR port.

If we use Windows with WSL, we need to configure chokidar to use polling. (Vite uses chokidar.)

// package.json
{
  "scripts": {
    "dev": "CHOKIDAR_USEPOLLING=true npm run server"
  }
}

Note that it has been reported that vite.config.js#server.watch.usePolling doesn't work.

See also: