Containerfile
Raw
1# --- build stage -------------------------------------------------------------
2# Use the Alpine-flavored Bun image so the compiled binary is musl-linked and
3# runs directly on the Alpine runtime image below.
4FROM oven/bun:1-alpine AS build
5WORKDIR /app
6
7# Install deps first for better layer caching.
8COPY package.json bun.lock ./
9RUN bun install --frozen-lockfile
10
11# Build the client bundles into assets/dist, then compile the server into a
12# single standalone binary that embeds the Bun runtime.
13COPY . .
14RUN bun run build && bun build --compile src/index.ts --outfile zbin-server
15
16# --- runtime stage -----------------------------------------------------------
17FROM alpine:3.21
18WORKDIR /app
19
20# The musl-linked Bun binary still dynamically links libstdc++/libgcc.
21# catatonit is a tiny init that reaps zombies and forwards signals to the server.
22RUN apk add --no-cache libstdc++ libgcc catatonit
23
24# The compiled server plus the static assets it serves from ./assets at runtime.
25COPY --from=build /app/zbin-server ./zbin-server
26COPY --from=build /app/assets ./assets
27
28EXPOSE 3000
29ENTRYPOINT ["/usr/bin/catatonit", "--"]
30CMD ["./zbin-server"]
31