FROM git.luke-else.co.uk/luke-else/nodejs:latest AS build

WORKDIR /app

COPY package*.json ./
RUN rm -rf node_modules
RUN rm -rf build
COPY . .
RUN pnpm install
RUN pnpm run build

FROM git.luke-else.co.uk/luke-else/nodejs:latest AS run

WORKDIR /app
COPY --from=build /app/package.json ./package.json
COPY --from=build /app/build ./build
RUN pnpm install --prod

EXPOSE 3000
ENTRYPOINT [ "pnpm", "run", "start" ]
