From 3dc6fe2648d4db4c5ceda7ae00c4eb7577f49780 Mon Sep 17 00:00:00 2001 From: gunshiz Date: Sat, 29 Aug 2026 05:47:25 +0000 Subject: [PATCH] feat(ops): package app worker and migrations --- .dockerignore | 13 ++++++++++++ Dockerfile | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..1eccca0 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,13 @@ +.git +.gitea +.next +.env +.env.* +!.env.example +node_modules +coverage +playwright-report +test-results +*.tsbuildinfo +npm-debug.log* +bun-error.log* diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c8627ae --- /dev/null +++ b/Dockerfile @@ -0,0 +1,57 @@ +# syntax=docker/dockerfile:1.7 + +ARG BUN_VERSION=1.3.14 + +FROM oven/bun:${BUN_VERSION} AS dependencies +WORKDIR /app +COPY package.json bun.lock ./ +RUN bun install --frozen-lockfile + +FROM dependencies AS worker-builder +WORKDIR /app +COPY . . +RUN bun build scripts/outbox-worker.ts \ + --target=bun \ + --minify \ + --outfile=dist/outbox-worker.js + +FROM node:22-bookworm-slim AS next-builder +WORKDIR /app +ARG NEXT_DEPLOYMENT_ID=container-build +ENV NEXT_DEPLOYMENT_ID=${NEXT_DEPLOYMENT_ID} +ENV NEXT_TELEMETRY_DISABLED=1 +COPY --from=dependencies /app/node_modules ./node_modules +COPY . . +# Bun 1.3.14 can crash after a successful Next build on arm64. The application +# still runs on Bun; Node is used only for the deterministic compiler process. +RUN node node_modules/next/dist/bin/next build + +FROM dependencies AS migration +WORKDIR /app +ARG VCS_REF=unknown +LABEL org.opencontainers.image.title="Buzz Sheet migrations" \ + org.opencontainers.image.revision=${VCS_REF} +ENV NODE_ENV=production +COPY --chown=bun:bun db ./db +COPY --chown=bun:bun drizzle ./drizzle +COPY --chown=bun:bun scripts/migrate.ts ./scripts/migrate.ts +COPY --chown=bun:bun tsconfig.json ./tsconfig.json +USER bun +ENTRYPOINT ["bun", "scripts/migrate.ts"] + +FROM oven/bun:${BUN_VERSION} AS app +WORKDIR /app +ARG VCS_REF=unknown +LABEL org.opencontainers.image.title="Buzz Sheet" \ + org.opencontainers.image.revision=${VCS_REF} +ENV HOSTNAME=0.0.0.0 +ENV NODE_ENV=production +ENV NEXT_TELEMETRY_DISABLED=1 +ENV PORT=3000 +COPY --from=next-builder --chown=bun:bun /app/.next/standalone ./ +COPY --from=next-builder --chown=bun:bun /app/.next/static ./.next/static +COPY --from=next-builder --chown=bun:bun /app/public ./public +COPY --from=worker-builder --chown=bun:bun /app/dist/outbox-worker.js ./worker/outbox-worker.js +USER bun +EXPOSE 3000 +CMD ["bun", "server.js"]