From 1149404e7bc6d555f694718aab71ce6fd0af9ad7 Mon Sep 17 00:00:00 2001 From: timochan Date: Wed, 10 Jul 2024 20:57:09 +0800 Subject: [PATCH] chore: update --- Dockerfile | 44 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index 26a4cda..7ccbced 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,20 +1,46 @@ -# Rebuild the source code only when needed -FROM node:18-alpine +FROM node:20-alpine AS builder -RUN apk add libc6-compat git && \ - npm i -g pnpm pm2 +RUN apk add --no-cache libc6-compat git +RUN npm i -g pnpm +WORKDIR /app +COPY . . + +RUN pnpm install +RUN npm run build +# If using npm comment out above and use below instead +# RUN npm run build + +# Production image, copy all the files and run next +FROM node:20-alpine AS runner WORKDIR /app -RUN git clone https://github.com/ttimochan/kami.git --depth 1 . + +ENV NODE_ENV production ENV BASE_URL=https://www.timochan.cn +ENV BASE_URL=${BASE_URL} ENV NEXT_PUBLIC_API_URL=${BASE_URL}/api ENV NEXT_PUBLIC_GATEWAY_URL=${BASE_URL} -RUN node -e "console.log(process.env)" && \ - pnpm install && \ - npm run build +RUN node -e "console.log(process.env)" +# Uncomment the following line in case you want to disable telemetry during runtime. +# ENV NEXT_TELEMETRY_DISABLED 1 + +RUN addgroup --system --gid 1001 nodejs +RUN adduser --system --uid 1001 nextjs + +# You only need to copy next.config.mjs if you are NOT using the default configuration +COPY --from=builder /app/next.config.mjs ./ +COPY --from=builder /app/public ./public +COPY --from=builder /app/package.json ./package.json + +# Automatically leverage output traces to reduce image size +# https://nextjs.org/docs/advanced-features/output-file-tracing +COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ +COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static + +USER nextjs EXPOSE 2323 ENV PORT 2323 -CMD echo "Mix Space Web [Kami] Image." && sh \ No newline at end of file +CMD echo "Mix Space Web [Kami] Image." && node server.js \ No newline at end of file