Skip to content

Commit

Permalink
fix: docker fix
Browse files Browse the repository at this point in the history
  • Loading branch information
VineeTagarwaL-code committed Oct 6, 2024
1 parent a132042 commit 11a69be
Showing 1 changed file with 30 additions and 6 deletions.
36 changes: 30 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,31 +1,55 @@
# Base stage
FROM node:20-alpine AS base
WORKDIR /usr/src/app

# Copy the .env file
COPY .env .env

# Copy the necessary files
COPY package*.json ./
COPY ./prisma ./prisma
RUN npm install && npx prisma generate

# Install dependencies
RUN npm install

# Use the .env file for the Prisma client generation
RUN npx prisma generate --schema=./prisma/schema.prisma

# Development stage
FROM node:20-alpine AS development
WORKDIR /usr/src/app
COPY . .
COPY --from=base /usr/src/app/node_modules ./node_modules
CMD ["npm", "run", "dev:docker"]

# WIP
# Build stage
FROM node:20-alpine AS build
ARG DATABASE_URL
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
COPY . .
RUN DATABASE_URL=$DATABASE_URL npx prisma generate
RUN DATABASE_URL=$DATABASE_URL npm run build

# Copy .env file into the build stage
COPY --from=base /usr/src/app/.env .env

# Install dependencies and generate Prisma client using the .env file
RUN npm install
RUN npx prisma generate --schema=./prisma/schema.prisma

# Build the Next.js application
RUN npm run build

# Production stage
FROM node:20-alpine AS production
WORKDIR /usr/src/app

# Copy the necessary files from the build stage
COPY --from=build /usr/src/app/.next ./.next
COPY --from=build /usr/src/app/node_modules ./node_modules
COPY --from=build /usr/src/app/public ./public
COPY --from=build /usr/src/app/package.json ./package.json
COPY --from=build /usr/src/app/.env .env

# Start the application with the .env file
CMD ["npm", "run", "start"]

EXPOSE 3000

0 comments on commit 11a69be

Please sign in to comment.