generated from defi-wonderland/web3-nextjs-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
51 lines (37 loc) · 1.19 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
# Use an official Node.js image as a parent image
FROM node:20 AS build
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
# # Install pnpm globally
# RUN npm install -g pnpm
# Set the working directory in the container
WORKDIR /app
# Copy pnpm-lock.yaml and package.json files
COPY package.json pnpm-lock.yaml ./
# Install dependencies using pnpm
RUN CI=1 pnpm install --frozen-lockfile
# Copy the rest of the application code
COPY . .
# Build the application
RUN pnpm build
# Use a lighter Node.js image for the final stage
FROM node:20-slim AS ui
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
ENV NODE_ENV=production
RUN corepack enable
# Set the working directory in the container
WORKDIR /app
# Copy only necessary files from the build stage
COPY --from=build /app/package.json /app/pnpm-lock.yaml ./
COPY --from=build /app/public ./public
COPY --from=build /app/.next/standalone ./
COPY --from=build /app/.next/static ./.next/static
# # Install only production dependencies with pnpm
# RUN CI=1 pnpm install --no-frozen-lockfile
# Expose the port on which the application will run
EXPOSE 5173
ENV PORT=5173
# Specify the command to run the application
CMD ["node", "server.js"]