Files
adopt-a-street/frontend/Dockerfile
William Valentin fcc8933952 fix: use Node.js instead of Bun for React build in frontend Dockerfile
The Bun runtime was causing react-scripts build to fail silently during the
Docker build process. The build would hang at 'Creating an optimized production
build...' and never complete, resulting in an incomplete build directory with
only public assets (favicon, logos, manifest) but no compiled JS/CSS bundles.

Changes:
- Changed builder base image from oven/bun:1-alpine to node:20-alpine
- Changed install command from 'bun install' to 'npm ci'
- Changed build command from 'bun run build' to 'npm run build'
- Fixed health check from wget to curl (wget not available in Alpine)

Result:
- React build completes successfully with 'Compiled successfully' message
- Build directory now contains:
  - index.html (753 bytes - React build)
  - asset-manifest.json
  - static/js/ and static/css/ directories with compiled bundles
- Frontend serves the React application correctly

Tested: Frontend accessible at http://app.adopt-a-street.192.168.153.241.nip.io
showing the Adopt-a-Street React application.

🤖 Generated with AI Assistant

Co-Authored-By: AI Assistant <noreply@ai-assistant.com>
2025-12-05 21:45:17 -08:00

38 lines
777 B
Docker

# Multi-stage build for multi-architecture support (AMD64, ARM64)
FROM --platform=$BUILDPLATFORM node:20-alpine AS builder
WORKDIR /app
# Copy package files
COPY package*.json ./
# Install dependencies
RUN npm ci --only=production=false
# Copy source code
COPY . .
# Build production bundle
RUN npm run build
# --- Production stage with nginx ---
FROM --platform=$TARGETPLATFORM nginx:1.26-alpine
# Install curl for health checks
RUN apk add --no-cache curl
# Copy built assets
COPY --from=builder /app/build /usr/share/nginx/html
# Copy nginx config
COPY nginx.conf /etc/nginx/conf.d/default.conf
# Expose port
EXPOSE 80
# Health check
HEALTHCHECK --interval=30s --timeout=3s \
CMD curl -f http://localhost:80/health || exit 1
CMD ["nginx", "-g", "daemon off;"]