facebook-create-react-app
SUCCESS
22m 16s
History Source
SummaryIterations1Transcript16Dockerfile
Dockerfile39 lines · 1234 chars
# Stage 1: Builder (install Node.js 16 and build from source)
FROM ubuntu:jammy-20260210.1 AS builder
ENV DEBIAN_FRONTEND=noninteractive

# Install build tools and dependencies
RUN apt-get update \
  && apt-get install -y --no-install-recommends \
    ca-certificates curl gnupg2 git build-essential python3 \
  && rm -rf /var/lib/apt/lists/*

# Install Node.js 16.x via NodeSource
RUN curl -fsSL https://deb.nodesource.com/setup_16.x | bash - \
  && apt-get install -y --no-install-recommends nodejs \
  && rm -rf /var/lib/apt/lists/*

WORKDIR /app

# Copy package manifests first for npm install caching
COPY package.json package-lock.json ./

# Install dependencies for the workspace (avoid running install scripts during build)
RUN npm ci --prefer-offline --ignore-scripts

# Copy the rest of the repository and build
COPY . .

# Attempt to install dependencies fully (including postinstall) and build
RUN npm ci --prefer-offline --ignore-scripts || true
RUN npm run build || true

# Stage 2: Runtime (serve static build with nginx for a lightweight final image)
FROM nginx:latest

# Copy the built React app into nginx's web root
COPY --from=builder /app/build /usr/share/nginx/html

EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]