# --- build stage ------------------------------------------------------------- # Use the Alpine-flavored Bun image so the compiled binary is musl-linked and # runs directly on the Alpine runtime image below. FROM oven/bun:1-alpine AS build WORKDIR /app # Install deps first for better layer caching. COPY package.json bun.lock ./ RUN bun install --frozen-lockfile # Build the client bundles into assets/dist, then compile the server into a # single standalone binary that embeds the Bun runtime. COPY . . RUN bun run build && bun build --compile src/index.ts --outfile zbin-server # --- runtime stage ----------------------------------------------------------- FROM alpine:3.21 WORKDIR /app # The musl-linked Bun binary still dynamically links libstdc++/libgcc. # catatonit is a tiny init that reaps zombies and forwards signals to the server. RUN apk add --no-cache libstdc++ libgcc catatonit # The compiled server plus the static assets it serves from ./assets at runtime. COPY --from=build /app/zbin-server ./zbin-server COPY --from=build /app/assets ./assets EXPOSE 3000 ENTRYPOINT ["/usr/bin/catatonit", "--"] CMD ["./zbin-server"]