-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
50 lines (37 loc) · 1.09 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
# SPDX-FileCopyrightText: 2024 PNED G.I.E.
#
# SPDX-License-Identifier: Apache-2.0
FROM registry.access.redhat.com/ubi9/nodejs-20-minimal:9.5-1733824671 AS base
# Install dependencies only when needed
FROM base AS deps
USER 0
WORKDIR /app
# Install dependencies based on the available lock file
COPY package.json ./
COPY package-lock.json ./
RUN npm ci --ignore-scripts
# Rebuild the source code only when needed
FROM base AS builder
USER 0
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
# Optional: Disable telemetry
# ENV NEXT_TELEMETRY_DISABLED 1
RUN npm run build
# Production image, copy all the files and run next
FROM base AS runner
USER 0
WORKDIR /app
ENV NODE_ENV production
# Optional: Disable telemetry at runtime
# ENV NEXT_TELEMETRY_DISABLED 1
COPY --from=builder /app/public ./public
# Ensure no write permissions for executable directories
COPY --from=builder --chown=1001:1001 /app/.next/standalone ./
COPY --from=builder --chown=1001:1001 /app/.next/static ./.next/static
USER 1001
EXPOSE 3000
ENV PORT 3000
ENV HOSTNAME "0.0.0.0"
CMD ["node", "server.js"]