Skip to content

Commit ccf6a87

Browse files
committed
fix: 도커파일 수정
1 parent 0094460 commit ccf6a87

3 files changed

Lines changed: 21 additions & 19 deletions

File tree

Dockerfile

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,38 @@
1-
# Install dependencies and build app
2-
FROM node:20-alpine AS builder
3-
1+
FROM node:20-alpine AS deps
42
WORKDIR /app
53

6-
ENV NODE_ENV=production
7-
8-
# pnpm 설치
9-
RUN corepack enable && corepack prepare pnpm@8.15.4 --activate
4+
RUN corepack enable
105

11-
# 의존성 관련 파일 복사 및 설치
12-
COPY pnpm-lock.yaml package.json ./
6+
COPY package.json pnpm-lock.yaml ./
137

148
RUN pnpm install --frozen-lockfile
159

16-
# 소스 코드 복사 및 빌드
10+
FROM node:20-alpine AS builder
11+
WORKDIR /app
12+
13+
RUN corepack enable
14+
ENV NODE_ENV=production
15+
ENV NEXT_TELEMETRY_DISABLED=1
16+
17+
COPY --from=deps /app/node_modules ./node_modules
1718
COPY . .
19+
1820
RUN pnpm build
1921

20-
# 런타임 컨테이너 설정
2122
FROM node:20-alpine AS runner
22-
2323
WORKDIR /app
2424

2525
ENV NODE_ENV=production
26+
ENV NEXT_TELEMETRY_DISABLED=1
27+
ENV PORT=3000
2628

27-
RUN corepack enable && corepack prepare pnpm@8.15.4 --activate
28-
29-
# package.json 필요 시 복사
30-
COPY --from=builder /app/package.json ./
29+
RUN addgroup -S nodejs && adduser -S nextjs -G nodejs
3130

32-
# Next.js standalone 모드로 복사
3331
COPY --from=builder /app/.next/standalone ./
3432
COPY --from=builder /app/.next/static ./.next/static
3533
COPY --from=builder /app/public ./public
3634

35+
USER nextjs
3736
EXPOSE 3000
3837

3938
CMD ["node", "server.js"]

next.config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import type { NextConfig } from "next";
22

33
const nextConfig: NextConfig = {
4-
/* config options here */
4+
reactStrictMode: false,
5+
output: "standalone",
56
};
67

78
export default nextConfig;

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
"start": "next start",
99
"lint": "eslint",
1010
"format": "prettier --write .",
11-
"format:check": "prettier --check ."
11+
"format:check": "prettier --check .",
12+
"docker:build": "docker build -t undefined-dev .",
13+
"docker:run": "docker run -p 3000:3000 undefined-dev"
1214
},
1315
"dependencies": {
1416
"class-variance-authority": "^0.7.1",

0 commit comments

Comments
 (0)