|
|
|
|
|
|
|
|
|
FROM node:18-slim AS base |
|
|
|
|
|
RUN apt-get update && apt-get install -y git |
|
|
|
|
|
WORKDIR /app |
|
RUN git clone https://github.com/huggingface/transformers.js-examples . |
|
|
|
|
|
WORKDIR /app/next-server |
|
|
|
|
|
FROM base AS deps |
|
|
|
|
|
RUN \ |
|
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \ |
|
elif [ -f package-lock.json ]; then npm ci; \ |
|
elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm i --frozen-lockfile; \ |
|
else echo "Lockfile not found." && exit 1; \ |
|
fi |
|
|
|
|
|
FROM base AS builder |
|
WORKDIR /app/next-server |
|
COPY --from=deps /app/next-server/node_modules ./node_modules |
|
COPY . . |
|
|
|
RUN \ |
|
if [ -f yarn.lock ]; then yarn run build; \ |
|
elif [ -f package-lock.json ]; then npm run build; \ |
|
elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm run build; \ |
|
else echo "Lockfile not found." && exit 1; \ |
|
fi |
|
|
|
|
|
FROM base AS runner |
|
WORKDIR /app/next-server |
|
|
|
ENV NODE_ENV=production |
|
|
|
RUN addgroup --system --gid 1001 nodejs |
|
RUN adduser --system --uid 1001 nextjs |
|
|
|
COPY --from=builder /app/next-server/public ./public |
|
|
|
|
|
RUN mkdir .next |
|
RUN chown nextjs:nodejs .next |
|
|
|
|
|
COPY --from=builder --chown=nextjs:nodejs /app/next-server/.next/standalone ./ |
|
COPY --from=builder --chown=nextjs:nodejs /app/next-server/.next/static ./.next/static |
|
|
|
USER nextjs |
|
|
|
|
|
RUN mkdir -p /app/next-server/node_modules/@huggingface/transformers/.cache |
|
RUN chmod 777 -R /app/next-server/node_modules/@huggingface/transformers/.cache |
|
|
|
EXPOSE 3000 |
|
|
|
ENV PORT=3000 |
|
ENV HOSTNAME="0.0.0.0" |
|
CMD ["node", "server.js"] |