/** * Dockerfile derivation — production image whose CMD is `oke start`. */ import { APP_PORT } from "../runtime/types.ts"; /** Options for {@link emitDockerfile}. */ export interface DockerfileOptions { /** App listen port. */ readonly appPort?: number; /** Bun base image. */ readonly baseImage?: string; } /** * Emit a production Dockerfile. CMD is exactly `oke start`. * * @param options - Port / base image */ export function emitDockerfile(options: DockerfileOptions = {}): string { const port = options.appPort ?? APP_PORT; const base = options.baseImage ?? "oven/bun:1.4"; return `# generated by oke docker — do not edit FROM ${base} AS deps WORKDIR /app COPY package.json bun.lock* ./ RUN bun install --frozen-lockfile --production FROM ${base} AS runner WORKDIR /app ENV NODE_ENV=production ENV PORT=${port} ENV PATH="/app/node_modules/.bin:\${PATH}" COPY --from=deps /app/node_modules ./node_modules COPY . . EXPOSE ${port} CMD ["oke", "start"] `; }