Optimize frontend Dockerfile with npm mirror
parent
29267c266e
commit
8b90ff7b28
|
|
@ -1,16 +1,19 @@
|
|||
# Stage 1: Build
|
||||
FROM swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/node:18-slim AS builder
|
||||
FROM swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/node:20-alpine AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Configure npm to use Aliyun mirror for faster installation
|
||||
RUN npm config set registry https://registry.npmmirror.com
|
||||
|
||||
# Copy package files
|
||||
COPY package.json package-lock.json ./
|
||||
COPY package.json yarn.lock* package-lock.json* ./
|
||||
|
||||
# Delete package-lock.json to avoid platform specific issues and force fresh resolution
|
||||
RUN rm package-lock.json
|
||||
|
||||
# Install dependencies
|
||||
RUN npm install --legacy-peer-deps
|
||||
# Clean install dependencies
|
||||
# 1. Remove lock file to solve cross-platform rollup issues
|
||||
# 2. Install with legacy-peer-deps for React 19 compatibility
|
||||
RUN rm -rf package-lock.json node_modules && \
|
||||
npm install --legacy-peer-deps
|
||||
|
||||
# Copy source code
|
||||
COPY . .
|
||||
|
|
@ -38,4 +41,4 @@ HEALTHCHECK --interval=30s --timeout=10s --retries=3 \
|
|||
CMD wget --quiet --tries=1 --spider http://localhost/ || exit 1
|
||||
|
||||
# Start nginx
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
|
|
|
|||
Loading…
Reference in New Issue