-
Notifications
You must be signed in to change notification settings - Fork 3
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
15 additions
and
35 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,49 +1,29 @@ | ||
FROM node:20-alpine AS base | ||
# Use the official Node.js image as the base image | ||
FROM node:lts-alpine | ||
|
||
FROM base AS deps | ||
RUN apk add --no-cache libc6-compat | ||
# Set the working directory inside the container | ||
WORKDIR /app | ||
|
||
# Copy package.json and package-lock.json to the working directory | ||
COPY package*.json ./ | ||
RUN npm ci | ||
|
||
FROM base AS builder | ||
WORKDIR /app | ||
COPY --from=deps /app/node_modules ./node_modules | ||
COPY . . | ||
# Install dependencies | ||
RUN npm install | ||
|
||
ENV NEXT_TELEMETRY_DISABLED 1 | ||
# Copy the rest of the app's source code to the working directory | ||
COPY . . | ||
|
||
# Dummy values for the environment variables | ||
ENV AUTH_SECRET="adf" | ||
ENV AUTH_GOOGLE_ID="adf" | ||
ENV AUTH_GOOGLE_SECRET="adf" | ||
ENV DATABASE_URL="postgres://user:password@db:5432/test_db" | ||
ENV RAZORPAY_KEY="adf" | ||
ENV RAZORPAY_SECRET="adf" | ||
ARG AUTH_SECRET="txxx#12" | ||
ENV AUTH_SECRET=$AUTH_SECRET | ||
|
||
# Prisma setup | ||
RUN npx prisma generate | ||
|
||
# Build the Next.js app | ||
RUN npm run build | ||
|
||
FROM base AS runner | ||
WORKDIR /app | ||
|
||
ENV NODE_ENV production | ||
ENV NEXT_TELEMETRY_DISABLED 1 | ||
|
||
RUN addgroup --system --gid 1001 nodejs | ||
RUN adduser --system --uid 1001 nextjs | ||
|
||
COPY --from=builder /app/public ./public | ||
COPY --from=builder --chown=nextjs:nodejs /app/.next ./.next | ||
COPY --from=builder /app/node_modules ./node_modules | ||
COPY --from=builder /app/package.json ./package.json | ||
|
||
USER nextjs | ||
|
||
# Expose the port that the app will run on | ||
EXPOSE 3000 | ||
|
||
ENV PORT 3000 | ||
|
||
CMD ["npm", "start"] | ||
# Start the app | ||
CMD ["npm", "start"] |