Yes, I am using two different builders. Below is my Dockerfile.
# using multistage build, as we need dev deps to build the TS source code
FROM apify/actor-node:20 AS builder
# copy all files, install all dependencies (including dev deps) and build the project
COPY . ./
RUN npm install --include=dev \
&& npm run build
# create final image
FROM apify/actor-node-playwright-chrome:18
# copy only necessary files
COPY --from=builder /usr/src/app/package.json ./
COPY --from=builder /usr/src/app/dist ./dist
COPY --from=builder /usr/src/app/INPUT_SCHEMA.json ./INPUT_SCHEMA.json
COPY --from=builder /usr/src/app/.npmrc ./.npmrc
# install only prod deps
USER root
RUN chown -R 999:999 ".npmrc"
RUN chown -R 999:999 ".npm"
USER myuser
RUN npm --quiet set progress=false \
&& npm install --only=prod --no-optional \
&& echo "Installed NPM packages:" \
&& (npm list --only=prod --no-optional --all || true) \
&& echo "Node.js version:" \
&& node --version \
&& echo "NPM version:" \
&& npm --version
# run compiled code
CMD npm run start:prod