-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cli): dockrize the application (#10)
* feat(cli): dockrize the application * Update Dockerfile Co-authored-by: Priyanshu Verma <[email protected]> --------- Co-authored-by: Priyanshu Verma <[email protected]>
- Loading branch information
1 parent
fa82e3b
commit 7ba03c3
Showing
1 changed file
with
47 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Stage 1: Base Node.js environment | ||
FROM node:18-alpine AS base | ||
|
||
# Set the working directory | ||
WORKDIR /app | ||
|
||
# Copy package manager lock files | ||
COPY package.json bun.lockb /app/ | ||
|
||
# Install Bun for faster dependency installation | ||
RUN npm install -g bun && bun install --frozen-lockfile | ||
|
||
# Copy the entire application code | ||
COPY . . | ||
|
||
# Stage 2: Build the application | ||
FROM base AS builder | ||
|
||
# Set environment variables for production | ||
ENV NODE_ENV=production | ||
|
||
# Build the Next.js application | ||
RUN bun run build | ||
|
||
# Remove development dependencies | ||
RUN bun install --production --frozen-lockfile | ||
RUN bunx prisma generate | ||
# Stage 3: Production-ready image | ||
FROM node:18-alpine AS production | ||
|
||
# Set the working directory | ||
WORKDIR /app | ||
|
||
# Set environment variables for production | ||
ENV NODE_ENV=production | ||
|
||
# Copy only the built application and necessary files | ||
COPY --from=builder /app/public /app/public | ||
COPY --from=builder /app/.next /app/.next | ||
COPY --from=builder /app/package.json /app/package.json | ||
COPY --from=builder /app/node_modules /app/node_modules | ||
|
||
# Expose the port the app runs on | ||
EXPOSE 3000 | ||
|
||
# Run the application | ||
CMD ["bun", "start"] |