diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..6180500 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,36 @@ +# Stage 1: Build stage +FROM node:18-alpine AS builder + +WORKDIR /app + +COPY package.json package-lock.json* ./ + +RUN npm ci --only=production=false + +COPY . . + +RUN npm run build + +# Stage 2: Production stage +FROM nginx:alpine AS production + +COPY --from=builder /app/build /usr/share/nginx/html + +# Create a simple nginx configuration for SPA +RUN echo 'server { \ + listen 80; \ + server_name localhost; \ + root /usr/share/nginx/html; \ + index index.html; \ + location / { \ + try_files $uri $uri/ /index.html; \ + } \ + location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ { \ + expires 1y; \ + add_header Cache-Control "public, immutable"; \ + } \ +}' > /etc/nginx/conf.d/default.conf + +EXPOSE 80 + +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file