-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.client
45 lines (33 loc) · 1.08 KB
/
Dockerfile.client
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
# Stage 1: Building the Next.js application
FROM node:20.9.0-alpine AS builder
WORKDIR /app
# Copy package.json and package-lock.json
COPY clients/dashboard/package*.json ./
# Install dependencies with caching
RUN npm config set @buf:registry https://buf.build/gen/npm/v1/
RUN --mount=type=cache,target=/root/.npm \
npm install --force
# Copy the rest of the application code
COPY clients/dashboard .
# Build the Next.js application
RUN --mount=type=cache,target=/root/.npm \
npm run build
# Stage 2: Running the Next.js application
FROM node:20.9.0-alpine AS runner
WORKDIR /app
# Copy built assets from the builder stage
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./package.json
COPY --from=builder /app/public ./public
# Set environment variables
ENV NODE_ENV production
ENV NEXT_TELEMETRY_DISABLED 1
# Add non-root user
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
USER nextjs
# Expose the port the app runs on
EXPOSE 3000
# Start the application
CMD ["npm", "start"]