feat(ops): package app worker and migrations
This commit is contained in:
+57
@@ -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"]
|
||||
Reference in New Issue
Block a user