Skip to content

Commit

Permalink
Refactor Dockerfile for improved npm dependency management and build …
Browse files Browse the repository at this point in the history
…process

- Updated npm installation commands to set legacy peer dependencies and install packages in a specific order.
- Cleaned npm cache and rebuilt before running the build command to ensure a fresh environment.
- Increased clarity and efficiency in the Dockerfile setup for the web application.
  • Loading branch information
xuwenyihust committed Dec 10, 2024
1 parent 5391709 commit 23726cf
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions webapp/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,22 @@ WORKDIR /app
# Copy package files
COPY package*.json ./

# Clean install with specific dependency resolution
# Clean and setup npm
RUN npm cache clean --force && \
npm install --legacy-peer-deps && \
npm set legacy-peer-deps=true

# Install dependencies in a specific order
RUN npm install && \
npm install @jridgewell/[email protected] && \
npm install @babel/[email protected]
npm install @babel/[email protected] && \
npm install @babel/[email protected]

# Copy the rest of the application
COPY . .

# Build with increased memory limit
ENV NODE_OPTIONS="--max-old-space-size=4096"
RUN npm run build
RUN npm rebuild && npm run build

# Stage 2: Serve the app with nginx
FROM nginx:stable-alpine
Expand Down

0 comments on commit 23726cf

Please sign in to comment.