This is my Dockerfile:
# Stage 1: Build the Angular app
FROM node:18 AS builder
WORKDIR /app
# Copy package.json and package-lock.json to install dependencies
COPY package.json package-lock.json ./
# Install Angular CLI globally
RUN npm install -g @angular/cli
# Install app dependencies
RUN npm install
# Clear Angular cache
RUN npx ngcc --clearCache
# Copy the entire Angular app source code to the container
COPY . .
# Build the Angular app for production
RUN ng build --base-href=/platform/ --configuration production --verbose
# Stage 2: Serve the Angular app using Nginx
FROM nginx:latest
# Copy the built Angular app from the previous stage to Nginx's default public directory
COPY --from=builder /app/dist/platform-ui /usr/share/nginx/html
# Copy a custom Nginx configuration if needed (e.g., for handling routing)
# COPY nginx.conf /etc/nginx/conf.d/default.conf
# Expose port 80 (default HTTP port for Nginx)
EXPOSE 80
Very simple file to build an angular application but each time build gets stuck in the build step RUN ng build --base-href=/platform/ --configuration production --verbose with the following error:
[webpack.cache.PackFileCacheStrategy] No pack exists at /app/.angular/cache/17.3.2/angular-webpack/d7b86a
=> => # c41a517ca254ba61ce464bfbbe390ffa5f.pack: Error: ENOENT: no such file or directory, stat '/app/.angular/cache/
=> => # 17.3.2/angular-webpack/d7b86ac41a517ca254ba61ce464bfbbe390ffa5f/index.pack'
I've tried to clean docker build's cache with the following command docker builder prune -a -f but still the same error, not sure why angular keeps reaing a cache although it's docker build, it's supposed to be an empty environment!!