Fix: update Dockerfile with build verification and npm install
This commit is contained in:
parent
fb8ccbb237
commit
8ce5060e88
1 changed files with 14 additions and 10 deletions
24
Dockerfile
24
Dockerfile
|
|
@ -1,37 +1,41 @@
|
||||||
# ---------------------------------------------------------
|
# ---------------------------------------------------------
|
||||||
# ---------------------------------------------------------
|
|
||||||
# Build stage
|
# Build stage
|
||||||
# ---------------------------------------------------------
|
# ---------------------------------------------------------
|
||||||
FROM node:18-alpine AS builder
|
FROM node:18-alpine AS builder
|
||||||
|
|
||||||
# Install git (only needed for npm postinstall scripts)
|
# Install git (needed by some npm packages)
|
||||||
RUN apk add --no-cache git
|
RUN apk add --no-cache git
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Copy package files
|
# Copy only package files first (leverages caching)
|
||||||
COPY package.json ./
|
COPY package.json package-lock.json* ./
|
||||||
|
|
||||||
|
# Install dependencies (npm ci uses lockfile, but we don't have it)
|
||||||
|
# Using npm install instead for broader compatibility
|
||||||
RUN npm install
|
RUN npm install
|
||||||
|
|
||||||
# Copy the rest of the source tree
|
# Copy source files
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# Build the production bundle (Vite outputs to `dist/`)
|
# Build the production bundle (outputs to /app/dist)
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
# DEBUG: Confirm build output exists before proceeding
|
# DEBUG: Verify the build output exists before proceeding
|
||||||
RUN echo "=== BUILD OUTPUT CHECK ===" && \
|
RUN echo "=== BUILD OUTPUT ===" && \
|
||||||
ls -la /app/dist && \
|
ls -la /app/dist && \
|
||||||
cat /app/dist/index.html 2>/dev/null | head -n 5 || echo "ERROR: INDEX NOT FOUND - build may have failed silently"
|
cat /app/dist/index.html | head -n 10 || echo "ERROR: index.html missing"
|
||||||
|
|
||||||
# ---------------------------------------------------------
|
# ---------------------------------------------------------
|
||||||
# Production stage – tiny static server (nginx)
|
# Production stage – nginx serving the static files
|
||||||
# ---------------------------------------------------------
|
# ---------------------------------------------------------
|
||||||
FROM nginx:alpine
|
FROM nginx:alpine
|
||||||
|
|
||||||
|
# Custom nginx config
|
||||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||||
|
|
||||||
|
# Copy the compiled React app into nginx's web root
|
||||||
COPY --from=builder /app/dist /usr/share/nginx/html
|
COPY --from=builder /app/dist /usr/share/nginx/html
|
||||||
|
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue