-
Notifications
You must be signed in to change notification settings - Fork 456
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
a132042
commit 11a69be
Showing
1 changed file
with
30 additions
and
6 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,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 |