f71952f838
CI / build (push) Has been cancelled
The migrate task chained db:seed, so every production deploy inserted demo users, duplicate Sunday templates and 45 fake assignments, and its unconditional assignment delete wiped real schedule data. Migrations now run alone, and the seed aborts when the database already holds non-seed users unless SEED_FORCE=1 is set for a throwaway database. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
62 lines
2.5 KiB
Docker
62 lines
2.5 KiB
Docker
# ---------------------------------------------------------------------------
|
|
# Media Team Hub — portable, containerized Next.js app.
|
|
# Multi-stage: build in an alpine/node image, run a lean runner image.
|
|
# The app is standard HTTP on :3000 — sit it behind your reverse proxy.
|
|
# ---------------------------------------------------------------------------
|
|
|
|
FROM node:22-alpine AS base
|
|
WORKDIR /app
|
|
ENV NODE_ENV=production
|
|
# ImageMagick's LibRaw delegate decodes camera RAW files for the in-app editor;
|
|
# sharp does the tone rendering and JPEG encode. The Postgres client provides
|
|
# pg_dump/psql for admin backups and restores; unzip reads restore packages.
|
|
RUN apk add --no-cache imagemagick libraw ffmpeg exiv2 postgresql16-client unzip
|
|
# pnpm is how this project is built (see package.json scripts).
|
|
RUN npm install -g pnpm@9.15.0
|
|
|
|
FROM base AS builder
|
|
WORKDIR /app
|
|
COPY package.json pnpm-lock.yaml ./
|
|
# Frozen install — fails the build if the lockfile is out of sync.
|
|
RUN pnpm install --frozen-lockfile
|
|
COPY . .
|
|
RUN pnpm build
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Tools stage — migrations + seed run from the builder image, which has the
|
|
# source, `drizzle/` and dev dependencies (drizzle-kit, tsx). Keeping them out of
|
|
# the runner keeps the serving image lean.
|
|
# ---------------------------------------------------------------------------
|
|
FROM builder AS tools
|
|
ENV NODE_ENV=development
|
|
CMD ["pnpm", "db:migrate"]
|
|
|
|
FROM base AS runner
|
|
WORKDIR /app
|
|
ENV NODE_ENV=production
|
|
# Inherits pnpm and the ImageMagick/LibRaw runtime tools from `base`.
|
|
|
|
# Run as a non-root user (busybox adduser/addgroup on alpine).
|
|
RUN addgroup -S nodegrp \
|
|
&& adduser -S -G nodegrp -H -D nextjs
|
|
|
|
# Some ImageMagick temporary work happens under /tmp; it is writable by all.
|
|
RUN chmod 1777 /tmp
|
|
|
|
# Build output, deps, static assets.
|
|
COPY --from=builder --chown=nextjs:nodegrp /app/public ./public
|
|
COPY --from=builder --chown=nextjs:nodegrp /app/node_modules ./node_modules
|
|
COPY --from=builder --chown=nextjs:nodegrp /app/package.json ./package.json
|
|
COPY --from=builder --chown=nextjs:nodegrp /app/.next ./.next
|
|
|
|
# The console email transport writes here. Create it in the image owned by the
|
|
# runtime user so a mounted named volume inherits that ownership (a root-owned
|
|
# volume made every send fail with EACCES in the first deploy).
|
|
RUN mkdir -p /tmp/outbox /tmp/uploads /archive && chown -R nextjs:nodegrp /tmp/outbox /tmp/uploads /archive
|
|
|
|
USER nextjs
|
|
EXPOSE 3000
|
|
ENV PORT=3000
|
|
ENV HOSTNAME=0.0.0.0
|
|
CMD ["pnpm", "start"]
|