forked from hitesh22rana/chronoverse
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.dashboard
More file actions
58 lines (44 loc) · 1.41 KB
/
Copy pathDockerfile.dashboard
File metadata and controls
58 lines (44 loc) · 1.41 KB
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
58
# Stage 1: Dependencies
FROM node:25-alpine3.21 AS deps
WORKDIR /app
# Install dependencies based on the preferred package manager
COPY dashboard/package.json dashboard/package-lock.json* ./
RUN npm ci
# Stage 2: Builder
FROM node:25-alpine3.21 AS builder
WORKDIR /app
# Build arguments
ARG NEXT_PUBLIC_API_URL
# Copy dependencies
COPY --from=deps /app/node_modules ./node_modules
COPY dashboard .
# Set build-time environment variables
ENV NEXT_TELEMETRY_DISABLED=1
ENV NODE_ENV=production
ENV NEXT_PUBLIC_API_URL=$NEXT_PUBLIC_API_URL
# Build the application
RUN npm run build
# Stage 3: Runner
FROM node:25-alpine3.21 AS runner
WORKDIR /app
# Set runtime environment variables
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
ENV PORT=3000
# Create a non-root user to run the app and own app files
RUN addgroup --system --gid 1001 nodejs && \
adduser --system --uid 1001 nextjs
# Copy only necessary files from the builder stage
COPY --from=builder --chown=nextjs:nodejs /app/public ./public
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
# Set the correct permission for prerender cache
RUN mkdir -p .next/cache && \
chown -R nextjs:nodejs .next && \
chmod -R 755 .next/cache
# Switch to non-root user
USER nextjs
# Expose the port the app will run on
EXPOSE 3000
# Start the application
CMD ["node", "server.js"]