vision-agent-landing / Dockerfile
wuyiqun0718's picture
test
9612307
raw
history blame
1.28 kB
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"]