Unable to deploy angular in production mode.

Hello, guys!

I am trying to deploy a full-stack app. The main directory belongs to my node.js server app.
Inside it I have a frontend folder, where all my angular code is.

The problem is that client code is always built in development mode, even though I tell docker to run npm run build --prod command.

Locally everything works as expected. That’s why I decided to ask the help of community.

Here is my docker file:

FROM node:16-alpine as client_builder

RUN mkdir /usr/src

RUN mkdir /usr/src/frontend

WORKDIR /usr/src/frontend

COPY ./frontend /usr/src/frontend

RUN npm i

RUN npm run build --prod

FROM node:16-alpine as server_builder

RUN mkdir /usr/src

RUN mkdir /usr/src/server

WORKDIR /usr/src/server

COPY package*.json ./

RUN npm i

COPY . .

RUN npm run build:server

RUN npm prune --production

FROM node:16-alpine as production

ARG NODE_ENV=production

ENV NODE_ENV=${NODE_ENV}

WORKDIR /usr/src/

COPY package*.json ./

RUN npm install --only=production

COPY . .

COPY --from=server_builder --chown=node:node /usr/src/server/package*.json ./

COPY --from=server_builder --chown=node:node /usr/src/server/node_modules/ ./node_modules/

COPY --from=server_builder --chown=node:node /usr/src/server/dist/ ./dist/

COPY --from=client_builder --chown=node:node /usr/src/frontend/dist ./dist/

CMD ["node", "dist/main"]

Also, if you have ideas how to improve it, I am open to any ideas. I am not a guru in docker.

Just a hunch (not sure about this) :
I think the --prod option will apply to the RUN command here instead of the npm run build command.

Could you try creating a script that runs the npm run build --prod command, and then running that script using RUN?

I guess, I found the problem. It is not related to fly.io.

Sorry.