-
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
1 parent
4974219
commit 77c235b
Showing
3 changed files
with
58 additions
and
20 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,22 +1,61 @@ | ||
FROM node:20-alpine | ||
ARG NEXT_PUBLIC_IS_PRODUCTION | ||
ARG NEXT_PUBLIC_PAY_U_KEY_TEST | ||
ARG NEXT_PUBLIC_PAY_U_KEY_PROD | ||
|
||
FROM node:20-alpine AS base | ||
|
||
FROM base AS deps | ||
RUN apk add --no-cache libc6-compat | ||
WORKDIR /app | ||
|
||
WORKDIR /anokha | ||
# Install dependencies based on the preferred package manager | ||
COPY package.json package-lock.json* ./ | ||
RUN npm i --force; | ||
|
||
# Rebuild the source code only when needed | ||
FROM base AS builder | ||
WORKDIR /app | ||
COPY --from=deps /app/node_modules ./node_modules | ||
COPY . . | ||
|
||
# Set environment variables needed for build | ||
ARG NEXT_PUBLIC_IS_PRODUCTION | ||
ARG NEXT_PUBLIC_PAY_U_KEY_TEST | ||
ARG NEXT_PUBLIC_PAY_U_KEY_PROD | ||
# Pass them to the build process | ||
ENV NEXT_PUBLIC_IS_PRODUCTION=${NEXT_PUBLIC_IS_PRODUCTION} | ||
ENV NEXT_PUBLIC_PAY_U_KEY_TEST=${NEXT_PUBLIC_PAY_U_KEY_TEST} | ||
ENV NEXT_PUBLIC_PAY_U_KEY_PROD=${NEXT_PUBLIC_PAY_U_KEY_PROD} | ||
|
||
RUN npm run build; | ||
|
||
# Production image, copy all the files and run next | ||
FROM base AS runner | ||
WORKDIR /app | ||
|
||
ENV NODE_ENV=production | ||
|
||
# Pass them to the build process | ||
ENV NEXT_PUBLIC_IS_PRODUCTION=${NEXT_PUBLIC_IS_PRODUCTION} | ||
ENV NEXT_PUBLIC_PAY_U_KEY_TEST=${NEXT_PUBLIC_PAY_U_KEY_TEST} | ||
ENV NEXT_PUBLIC_PAY_U_KEY_PROD=${NEXT_PUBLIC_PAY_U_KEY_PROD} | ||
|
||
RUN npm i --force | ||
# Disable NextJS sending telemetry data to Vercel | ||
ENV NEXT_TELEMETRY_DISABLED=1 | ||
|
||
RUN addgroup --system --gid 1001 nodejs | ||
RUN adduser --system --uid 1001 nextjs | ||
|
||
COPY --from=builder /app/public ./public | ||
|
||
# Set the correct permission for prerender cache | ||
RUN mkdir .next | ||
RUN chown nextjs:nodejs .next | ||
|
||
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ | ||
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static | ||
|
||
USER nextjs | ||
|
||
EXPOSE 3002 | ||
|
||
RUN npm run build | ||
ENV PORT=3002 | ||
|
||
CMD ["npm","run","start"] | ||
ENV HOSTNAME="0.0.0.0" | ||
CMD ["node", "server.js"] |
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