forked from emergentmethods/flowdapt-dashboard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
53 lines (37 loc) · 1.19 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
ARG NODE_VERSION=20
# Alpine image
FROM node:${NODE_VERSION}-alpine AS alpine
RUN apk update
RUN apk add --no-cache libc6-compat
# Setup pnpm on the alpine base
FROM alpine as base
RUN npm install pnpm --global
RUN pnpm config set store-dir ~/.pnpm-store
# Build the project
FROM base AS builder
WORKDIR /app
COPY package.json pnpm-lock.yaml ./
# First install the dependencies (as they change less often)
RUN --mount=type=cache,id=pnpm,target=~/.pnpm-store pnpm install --frozen-lockfile
# Copy source code
COPY . .
ENV NEXT_TELEMETRY_DISABLED 1
RUN pnpm build
# Final image
FROM alpine AS runner
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nodejs
USER nodejs
WORKDIR /app
COPY --from=builder --chown=nodejs:nodejs /app/next.config.js .
COPY --from=builder --chown=nodejs:nodejs /app/package.json .
# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=builder --chown=nodejs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nodejs:nodejs /app/.next/static ./.next/static
WORKDIR /app
ARG PORT=3030
ENV PORT=${PORT}
ENV NODE_ENV=production
EXPOSE ${PORT}
CMD ["node", "server.js"]