Spaces:
Sleeping
Sleeping
File size: 1,275 Bytes
4831513 478d5b9 4831513 478d5b9 159e7fa 478d5b9 4cb92f9 159e7fa 478d5b9 16c0c7e 478d5b9 9011efd f36ff11 478d5b9 1e06f84 478d5b9 1e06f84 478d5b9 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
FROM node:20 AS base
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
FROM base AS deps
WORKDIR /app
COPY package.json pnpm-lock.yaml prisma/* ./
RUN pnpm i --frozen-lockfile
# Rebuild the source code only when needed
FROM base AS builder
WORKDIR /app
COPY --from=deps --link /app/node_modules ./node_modules
COPY --link . .
RUN --mount=type=secret,id=AUTH_SECRET \
--mount=type=secret,id=OPENAI_API_KEY \
AUTH_SECRET="$(cat /run/secrets/AUTH_SECRET)" \
OPENAI_API_KEY="$(cat /run/secrets/OPENAI_API_KEY)" \
USE_STANDALONE_BUILD=True \
pnpm run build
RUN mkdir -p /app/.next/cache/images
# Production image, copy all the files and run next
FROM base AS runner
WORKDIR /app
ENV NODE_ENV production
COPY --from=builder --link /app/public ./public
# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --chown=nextjs:nodejs --from=builder /app/ ./
COPY --from=builder --link --chown=1000:1000 /app/.next/standalone ./
COPY --from=builder --link --chown=1000:1000 /app/.next/static ./.next/static
COPY --from=builder --link --chown=1000:1000 /app/.next/cache/images ./.next/cache/images
EXPOSE 3000
ENV PORT 3000
ENV HOSTNAME 0.0.0.0
CMD ["node", "server.js"]
|