diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..f5a7eed --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,11 @@ +# docker-compose.yml +version: '3.8' + +services: + react-app: + build: . + ports: + - "3000:80" # Changed host port + environment: + - NODE_ENV=production + restart: unless-stopped \ No newline at end of file diff --git a/docker/nginx/nginx.conf b/docker/nginx/nginx.conf new file mode 100644 index 0000000..2a58950 --- /dev/null +++ b/docker/nginx/nginx.conf @@ -0,0 +1,15 @@ +server { + listen 80; + server_name localhost; + + location / { + root /usr/share/nginx/html; + index index.html index.htm; + try_files $uri $uri/ /index.html; + } + + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } +} \ No newline at end of file diff --git a/dockerfile b/dockerfile new file mode 100644 index 0000000..1dbfb28 --- /dev/null +++ b/dockerfile @@ -0,0 +1,32 @@ +# Build stage +FROM node:22-alpine AS builder + +WORKDIR /app + +# Install system dependencies (if needed) +RUN apk add --no-cache python3 make g++ + +# Copy package files +COPY package*.json ./ + +# Install dependencies +RUN npm install --legacy-peer-deps + +# Copy source code +COPY . . + +# Build React app +RUN npm run build + +# Production stage +FROM nginx:1.25-alpine + +# Copy nginx config +COPY docker/nginx/nginx.conf /etc/nginx/conf.d/default.conf + +# Copy build artifacts +COPY --from=builder /app/build /usr/share/nginx/html + +# Expose and run +EXPOSE 80 +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file