Sign inSign up

ogulcanaydogan/react-nginx

By ogulcanaydogan

•Updated 9 months ago

Production-ready container for React applications with Nginx

Image
0

843

ogulcanaydogan/react-nginx repository overview

⁠React Nginx

Production-ready container for React applications with Nginx.

⁠Quick Start

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

⁠Features

  • Optimized for React apps
  • Flexible port configuration
  • React Router support (client-side routing)
  • Gzip compression
  • Multi-stage build ready
  • Health check included

⁠Environment Variables

VariableDescriptionDefault
PORTServer port80
SPA_MODEClient-side routing fallbacktrue

⁠Docker Compose Example

services:
  frontend:
    build: .
    ports:
      - "80:80"

⁠License

MIT

Tag summary

Content type

Image

Digest

sha256:458e60fd6…

Size

26 MB

Last updated

9 months ago

docker pull ogulcanaydogan/react-nginx