# --- Build --- FROM oven/bun:latest AS build WORKDIR /app # Copy lockfile and package.json to cache dependencies COPY package.json bun.lockb ./ # Install dependencies needed for the D2 installer # oven/bun:latest is Debian-based, so we use apt-get RUN apt-get update && apt-get install -y \ curl \ build-essential \ ca-certificates \ && rm -rf /var/lib/apt/lists/* # Install D2 and VERIFY immediately # Adding 'd2 --version' ensures the build stops if the install failed RUN curl -fsSL https://d2lang.com/install.sh | sh -s -- && d2 --version # Install dependencies RUN bun install --frozen-lockfile # Copy the rest of your source code COPY . . # Build the static site RUN bun run build # --- Runtime --- FROM nginx:stable-alpine AS runtime # Copy the custom nginx configuration COPY nginx.conf /etc/nginx/nginx.conf # Copy the static files from the build stage COPY --from=build /app/dist /usr/share/nginx/html # Give read permissions to Nginx over D2 generated assets RUN chmod -R 755 /usr/share/nginx/html/assets/d2 EXPOSE 8080