-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
53 lines (38 loc) · 1 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
# Base image
FROM node:20-alpine AS base
# Install dependencies layer
FROM base AS deps
RUN apk add --no-cache libc6-compat
WORKDIR /src
# Copy necessary files for yarn berry (PnP)
COPY .yarn ./.yarn
COPY .pnp.cjs ./
COPY .pnp.loader.mjs ./
COPY package.json yarn.lock* .yarnrc.yml ./
COPY .env .env
# Install dependencies with yarn berry
RUN yarn install --immutable
# Build layer
FROM base AS builder
WORKDIR /src
ENV NEXT_TELEMETRY_DISABLED 1
# Copy dependencies from deps stage
COPY --from=deps /src/ ./
# Copy the rest of the source code and build
COPY . .
RUN yarn build
# Production runner
FROM base AS runner
WORKDIR /src
ENV NODE_ENV=production
RUN addgroup --system --gid 1001 sixgroup
RUN adduser --system --uid 1001 challenger
# Copy build artifacts from builder stage
COPY --from=builder /src/public ./public
COPY --from=builder /src/.next ./.next
COPY --from=builder /src/package.json ./package.json
# Set up the permissions for the app
USER challenger
EXPOSE 3000
ENV PORT 3000
CMD ["yarn", "start"]