# ---- build ----
FROM oven/bun:alpine AS builder
WORKDIR /app

COPY package.json bun.lock tsconfig*.json ./
RUN bun install --frozen-lockfile

COPY src ./src
COPY assets ./assets

RUN bunx tsc -p tsconfig.build.json

# ---- runtime ----
FROM oven/bun:alpine AS runner
WORKDIR /app

ENV NODE_ENV=production
ENV IS_DOCKER=true

COPY package.json bun.lock ./
RUN bun install --frozen-lockfile --production

COPY --from=builder /app/dist ./dist
COPY --from=builder /app/assets ./assets

CMD [ "bun", "dist/index.js" ]