mirror of
https://github.com/jakejarvis/sofa.git
synced 2026-07-14 18:15:56 -04:00
Replace @libsql/client with bun:sqlite for zero-dependency SQLite access, swap drizzle-orm/libsql adapter for drizzle-orm/bun-sqlite, and rewrite Dockerfile to use oven/bun:1-alpine. The raw Database instance is no longer exported via Proxy (native C++ methods lose `this` binding through Reflect.get); instead, a closeDatabase() helper handles graceful shutdown and the health check uses Drizzle's db.run() directly. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
52 lines
1.2 KiB
Docker
52 lines
1.2 KiB
Docker
# syntax=docker/dockerfile:1
|
|
FROM oven/bun:1-alpine AS base
|
|
|
|
# --- Dependencies ---
|
|
FROM base AS deps
|
|
WORKDIR /app
|
|
|
|
COPY package.json bun.lock ./
|
|
|
|
RUN bun install --frozen-lockfile
|
|
|
|
# --- Builder ---
|
|
FROM base AS builder
|
|
WORKDIR /app
|
|
|
|
COPY --from=deps /app/node_modules ./node_modules
|
|
COPY . .
|
|
|
|
ARG GIT_COMMIT_SHA
|
|
ENV NODE_ENV=production
|
|
ENV GIT_COMMIT_SHA=${GIT_COMMIT_SHA}
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
|
|
RUN bun run build
|
|
|
|
# --- Runner ---
|
|
FROM base AS runner
|
|
WORKDIR /app
|
|
|
|
ENV NODE_ENV=production
|
|
ENV HOSTNAME=0.0.0.0
|
|
ENV PORT=3000
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
ENV DATA_DIR=/data
|
|
|
|
RUN mkdir -p /data \
|
|
&& chown bun:bun /data
|
|
|
|
COPY --from=builder --chown=bun:bun /app/public ./public
|
|
COPY --from=builder --chown=bun:bun /app/package.json ./package.json
|
|
COPY --from=builder --chown=bun:bun /app/.next/standalone ./
|
|
COPY --from=builder --chown=bun:bun /app/.next/static ./.next/static
|
|
COPY --from=builder --chown=bun:bun /app/drizzle ./drizzle
|
|
|
|
USER bun
|
|
EXPOSE 3000
|
|
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=15s --retries=3 \
|
|
CMD ["bun", "-e", "fetch('http://localhost:3000/api/health').then(r => process.exit(+!r.ok)).catch(() => process.exit(1))"]
|
|
|
|
CMD ["bun", "server.js"]
|