How to Dockerize a React App: A Step-by-Step Guide for Developers
A React (Vite + TypeScript) app can be containerized with two Dockerfiles: a development image that runs the Vite dev server with hot reload as the non-root node user, and a multi-stage production image that builds static assets with npm ci and serves them with the lightweight `serve` package. The guide also covers a thorough .dockerignore, build and run commands for both images, and a Compose file whose watch rules sync src changes and rebuild on package.json or vite.config changes. Nginx is noted as the traditional production choice for serving static files. Some leftover legacy snippets for Nginx and CRA appear in the code samples.
Related posts
- Build Apps in Deno with Frameworks such as React, Vue, Express, and more.
Deno mediumAdeptDeno 1.28's npm support lets you use npm-distributed frameworks like Express, React and Vue directly via `npm:` specifiers. You don't need package.json, node_modules or a separate install step, and Deno's built-in toolchain is available throughout. Step-by-step examples build a dinosaur API with Express. They then build the same dinosaur list/detail app in React (Vite scaffold via create-vite-extra, an Oak backend with CORS, react-router-dom) and in Vue (reactive store, Suspense, vue-router).
- Best-in-Class Developer Experience with Vite and Hydrogen
Shopify Engineering easyNoviceShopify's Hydrogen storefront framework is built on Vite. Vite serves user code as native ES Modules and pre-bundles and caches only third-party dependencies, which speeds up dev-server startup and hot module replacement compared with bundle-based tools like Webpack. Other reasons cited for the choice are ESBuild-based transforms, Rollup plugin compatibility, automatic CJS-to-ESM conversion, and SSR hooks that allow environment-specific transforms needed for React Server Components. Hydrogen wraps this in a single Vite plugin that composes four sub-plugins (hydrogen-config, react-server-dom-vite, hydrogen-middleware, plugin-react), while Webpack remains a fit for some advanced use cases.
- Build and Ship Astro Sites with Deno and Deno Deploy
Deno mediumAdeptAstro sites can be built with the Deno runtime and hosted on Deno Deploy in two modes. Static output from `npm run build` is served via the Deno standard library file server and auto-deployed from GitHub Actions. Server-rendered apps use Astro's `output: "server"` mode with a Deno adapter, a generated `server/entry.mjs` entrypoint, and npm scripts rewritten to run Astro through `deno run -A --unstable npm:astro`. A template app shows SSR form handling in component scripts, client-side delete calls to an API route, and data persistence that can be switched to Deno KV.
- What We Learned Migrating From Webpack to Vite
Neon mediumAdept
Neon moved its console, a set of SPAs whose HTML is rendered by a Go backend, from webpack to Vite. Because the backend generates the HTML, they built a ~150-line custom proxy on Vite's JS API and http-proxy that swaps production asset tags (marked with HTML comments) for Vite dev imports to enable HMR, while E2E tests bypass the proxy and use production bundles. Build time did not improve (20s to 22s) and cold dev page loads got slower (~1500 files), but the migration removed 17 direct dependencies, added HMR and unified config with Vitest and Storybook. Gotchas included the SWC React plugin panicking on syntax errors, CSS preload errors in production, entry-point name clashes with API routes, CSP adjustments for Vite's WebSocket and undefined process.env.
- Moving Railway's Frontend Off Next.js
Railway mediumAdeptRailway migrated its entire production frontend (dashboard, canvas, marketing site, 200+ routes) from the Next.js Pages Router to Vite + TanStack Router/Start in two PRs with zero downtime. The first PR removed all Next.js-specific dependencies such as next/image, next/head and next/router. The second swapped the framework, generating routes from the original page tree, moving 500+ redirects, headers and caching rules into Nitro config, and replacing Node polyfills with browser-native APIs. Builds dropped from over 10 minutes to under two. Railway gave up built-in image optimization (now handled by Fastly at the edge) and some ecosystem plugins, and accepted the immaturity of TanStack Start.