I am trying to Dockerize my Angular12 app. I am able to Dockerize it fine when building using development as the environment. However, when building as production (production as default build and ng serve environment) I am getting some esbuild error on the npm run build section of the Dockerfile.
Here is the error log (the .... after MZ was some special undecipherable characters originally) :
#15 1.112 > ng build
#15 1.112
#15 4.377 - Generating browser application bundles (phase: setup)...
#15 17.18 /app/node_modules/@angular-devkit/build-angular/node_modules/esbuild/esbuild.exe: 1: /app/node_modules/@angular-devkit/build-angular/node_modules/esbuild/esbuild.exe: MZ....: not found
#15 17.18 /app/node_modules/@angular-devkit/build-angular/node_modules/esbuild/esbuild.exe: 3: /app/node_modules/@angular-devkit/build-angular/node_modules/esbuild/esbuild.exe: Syntax error: end of file unexpected (expecting ")")
Here is the Dockerfile:
FROM node:16.8.0 as build-step
RUN mkdir -p /app
WORKDIR /app
COPY package.json /app
RUN npm install
COPY . /app
RUN npm run build
FROM nginx:1.20.1
COPY --from=build-step /app/dist/my-app /usr/share/nginx/html
EXPOSE 4200:80