FROM oven/bun:1 AS build

WORKDIR /app
COPY package.json bun.lock ./
COPY tsconfig.json components.json astro.config.ts ./
COPY patches ./patches
COPY public ./public
COPY src ./src

ENV ASTRO_ADAPTER=node
RUN bun install --frozen-lockfile
RUN bun run build

FROM node:22-bookworm-slim

WORKDIR /app
COPY --from=build /app/package.json ./package.json
COPY --from=build /app/node_modules ./node_modules
COPY --from=build /app/dist ./dist

ENV NODE_ENV=production
ENV HOST=0.0.0.0
ENV PORT=3000

EXPOSE 3000

CMD ["node", "dist/server/entry.mjs"]
