forked from arbisoft/session-portal-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
55 lines (39 loc) · 1.12 KB
/
Dockerfile
File metadata and controls
55 lines (39 loc) · 1.12 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
# Stage 1: Build the Next.js app
FROM node:22.14.0-alpine AS builder
ARG NEXT_PUBLIC_BASE_URL
ARG NEXT_PUBLIC_CLIENT_ID
ARG NEXT_PUBLIC_GTM_ID
ENV NEXT_PUBLIC_BASE_URL=${NEXT_PUBLIC_BASE_URL}
ENV NEXT_PUBLIC_CLIENT_ID=${NEXT_PUBLIC_CLIENT_ID}
ENV NEXT_PUBLIC_GTM_ID=${NEXT_PUBLIC_GTM_ID}
WORKDIR /app
# Install dependencies
COPY package.json package-lock.json ./
RUN npm ci
# Copy the rest of the app source code
COPY . .
# Build the app with standalone output
RUN npm run build
# Stage 2: Create a lightweight production image
FROM node:22.14.0-alpine AS runner
ARG UID=1001
ARG GID=1001
# Create non-root user
RUN addgroup -g $GID app && adduser -u $UID -G app -D -s /bin/false app
WORKDIR /app
ENV NODE_ENV=production \
PORT=4200 \
HOSTNAME="0.0.0.0" \
NEXT_TELEMETRY_DISABLED=1
# Copy standalone app and required files from builder
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
COPY --from=builder /app/public ./public
# # Fix ownership
RUN chown -R app:app /app
# # Use non-root user
USER app
# Default port for Next.js
EXPOSE 4200
# Start the app
CMD ["server.js"]