-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
46 lines (34 loc) · 1.39 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
ARG PLATFORM=linux/amd64
ARG BASE_IMAGE=node:18-alpine
# ===================== builder =====================
FROM --platform=${PLATFORM} ${BASE_IMAGE} AS builder
# Install necessary dependencies
RUN apk update && apk add --no-cache --update git && which yarn || npm install --global yarn
# Set the working directory to /app
WORKDIR /app
# Copy package.json and yarn.lock to the working directory
COPY package.json yarn.lock ./
# Install dependencies
RUN yarn install --production --frozen-lockfile
# Copy the rest of the application code to the working directory
COPY . .
RUN yarn build
# ====================== app ======================
FROM --platform=${PLATFORM} ${BASE_IMAGE} AS app
WORKDIR /app
# Define default env variables
ENV NODE_ENV production
ENV NEXT_TELEMETRY_DISABLED 1
ENV PORT 3000
RUN addgroup --system --gid 1001 ragnarokgrp && adduser --system --uid 1001 ragnarokusr
COPY --from=builder /app/public ./public
COPY --from=builder /app/package.json ./package.json
COPY --from=builder /app/.next/ ./
COPY --from=builder /app/yarn.lock .
# Automatically leverage output traces to reduce image size, see: https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=builder --chown=ragnarokusr:ragnarokgrp /app/.next/standalone ./
COPY --from=builder --chown=ragnarokusr:ragnarokgrp /app/.next/static ./.next/static
USER ragnarokusr
EXPOSE 3000
ENV PORT 3000
CMD ["node", "server.js"]