Skip to content

Commit

Permalink
revert Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
rabilrbl committed Apr 17, 2024
1 parent 2db7f4a commit 815104d
Showing 1 changed file with 15 additions and 35 deletions.
50 changes: 15 additions & 35 deletions Dockerfile
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"]

0 comments on commit 815104d

Please sign in to comment.