-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
35 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
CMD echo "Mix Space Web [Kami] Image." && node server.js |