FROM node:23 AS builder

WORKDIR /build
COPY package.json yarn.lock .yarnrc.yml .
RUN corepack yarn install

FROM node:23

RUN npm i -g tsx

USER 1000:1000
WORKDIR /app

## copy the necessary files after pulling deps
COPY --from=builder /build/node_modules node_modules
COPY tsconfig.json package.json cli .yarnrc.yml yarn.lock .
COPY src src

# make sure it passes compilation before publishing image
RUN corepack yarn tsc

ENTRYPOINT ["/app/cli"]