-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
57 lines (40 loc) · 1.25 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# Build Stage
FROM node:20-alpine AS build_image
# Set working directory
WORKDIR /app
# Install pnpm
RUN npm install -g pnpm
# First, copy only the package files
COPY package.json pnpm-lock.yaml ./
# Remove any existing node_modules to prevent conflicts
RUN rm -rf node_modules
# Install dependencies including Chakra UI
RUN pnpm install --frozen-lockfile && \
pnpm add @chakra-ui/theme @chakra-ui/react @emotion/react @emotion/styled framer-motion
# Copy the source code and environment variables
COPY . .
# Set Next.js to production mode
ENV NEXT_TELEMETRY_DISABLED 1
ENV NODE_ENV production
# Build the application
RUN pnpm run build
# Prune development dependencies
RUN pnpm prune --prod
# Production Stage
FROM node:20-alpine AS production_stage
# Set working directory
WORKDIR /app
# Install pnpm
RUN npm install -g pnpm
# Copy only necessary files from build stage
COPY --from=build_image /app/package.json /app/pnpm-lock.yaml ./
COPY --from=build_image /app/node_modules ./node_modules
COPY --from=build_image /app/.next ./.next
COPY --from=build_image /app/public ./public
# Set environment to production
ENV NODE_ENV production
ENV NEXT_TELEMETRY_DISABLED 1
# Expose port 3000
EXPOSE 3000
# Start the app in production mode
CMD ["pnpm", "start"]