FROM oven/bun:1.3-alpine AS base
WORKDIR /app

# Install dependencies
COPY package.json ./
COPY packages/db/package.json ./packages/db/
COPY packages/auth/package.json ./packages/auth/
COPY packages/shared/package.json ./packages/shared/
COPY packages/env/package.json ./packages/env/
COPY packages/config/package.json ./packages/config/
COPY packages/ui/package.json ./packages/ui/
COPY apps/server/package.json ./apps/server/

RUN bun install

# Copy source
COPY packages/db/ ./packages/db/
COPY packages/auth/ ./packages/auth/
COPY packages/shared/ ./packages/shared/
COPY packages/env/ ./packages/env/
COPY packages/config/ ./packages/config/
COPY apps/server/ ./apps/server/

WORKDIR /app/apps/server

# dotenv/config sucht nach .env — leere Datei verhindert Fehler (echte Werte kommen via --env-file)
RUN touch /app/apps/server/.env

EXPOSE 3000

CMD ["bun", "run", "src/index.ts"]
