-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile
53 lines (37 loc) · 1.15 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
# Use the official Node.js 18 image as a base
FROM node:18-alpine AS builder
# Set the working directory
WORKDIR /app
# Copy package.json and package-lock.json
COPY package*.json ./
# Skip cypress install
ENV CYPRESS_INSTALL_BINARY 0
# Install dependencies
RUN npm install --verbose
# Copy the rest of the application code
COPY . .
# Disable telemetry
ENV NEXT_TELEMETRY_DISABLED 1
# Set the build argument
ARG PROFILE
ARG NEXT_PUBLIC_BUILD_ID
# Rename environment files based on PROFILE
RUN cp .env.${PROFILE} .env.local
# Export the NEXT_PUBLIC_BUILD_ID as an environment variable
ENV NEXT_PUBLIC_BUILD_ID=${NEXT_PUBLIC_BUILD_ID}
# Build the Next.js application
RUN npm run build
# Use a minimal Node.js image for the production environment
FROM node:18-alpine AS runner
# Set the working directory
WORKDIR /app
# Copy the built application from the builder stage
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/public ./public
COPY --from=builder /app/package*.json ./
# Install production dependencies
RUN npm install --production
# Expose the port that Next.js will run on
EXPOSE 3000
# Start the Next.js application
CMD ["npm", "start"]