Production-ready container for React applications with Nginx
819
Production-ready container for React applications with Nginx.
Add this Dockerfile to your React project:
FROM node:20-alpine AS build
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
FROM ogulcanaydogan/static-server
# For Create React App:
COPY --from=build /app/build /usr/share/nginx/html
# For Vite:
# COPY --from=build /app/dist /usr/share/nginx/html
| Variable | Description | Default |
|---|---|---|
PORT | Server port | 80 |
SPA_MODE | Client-side routing fallback | true |
services:
frontend:
build: .
ports:
- "80:80"
MIT
Content type
Image
Digest
sha256:458e60fd6…
Size
26 MB
Last updated
7 months ago
docker pull ogulcanaydogan/react-nginx