# Dockerfile

FROM        oven/bun:latest AS base

WORKDIR     /var/task/

COPY        package.json bun.lock tsconfig.json vitest.config.ts ./

RUN         --mount=type=secret,id=GITHUB_NPM_TOKEN,required=true,uid=1000 \
            GITHUB_NPM_TOKEN=$(cat /run/secrets/GITHUB_NPM_TOKEN) && \
            printf '@theorchard:registry=https://npm.pkg.github.com\n//npm.pkg.github.com/:_authToken=%s\n' "$GITHUB_NPM_TOKEN" > .npmrc && \
            bun install --frozen-lockfile && \
            rm .npmrc


### Build dev
FROM        base AS dev

COPY        index.ts ./
COPY        __mocks__/ ./__mocks__
COPY        src/ ./src

ENTRYPOINT  []
CMD         ["/bin/sh"]


### Build unit/lint
FROM        dev AS unit-lint

RUN         touch .gitignore

COPY        scripts/ ./scripts
COPY        biome.json ./

ENTRYPOINT  ["scripts/unit-lint.sh"]
