# --- Release image ---
FROM node:22-alpine AS release
WORKDIR /home/node/app

RUN corepack enable

COPY ./dist/packages ./packages

COPY ./package.json ./

# Force node-modules linker (no .yarnrc.yml in build context)
RUN echo 'nodeLinker: node-modules' > .yarnrc.yml

RUN yarn install

RUN mkdir -p packages/node_modules && \
    ln -sf ../sim-shared packages/node_modules/sim-shared

COPY ./entrypoint.sh ./
RUN chmod +x entrypoint.sh

EXPOSE ${PORT:-3000}
ENTRYPOINT ["./entrypoint.sh"]
