From 0f266d0d94159b3a498d9234ef3ffe121d016363 Mon Sep 17 00:00:00 2001 From: jinddings Date: Tue, 12 Nov 2024 13:16:18 +0900 Subject: [PATCH] =?UTF-8?q?=E2=9A=99=EF=B8=8F=20chore:=20docker=20?= =?UTF-8?q?=EB=A9=80=ED=8B=B0=20=EC=8A=A4=ED=85=8C=EC=9D=B4=EC=A7=80=20?= =?UTF-8?q?=EC=82=AC=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BE/Dockerfile | 19 ++++++++++++++----- FE/Dockerfile | 15 +++++++-------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/BE/Dockerfile b/BE/Dockerfile index e23c0848..60079503 100644 --- a/BE/Dockerfile +++ b/BE/Dockerfile @@ -1,8 +1,17 @@ -FROM node:20 -RUN mkdir -p /var/app -WORKDIR /var/app -COPY . . +# 빌드 스테이지 +FROM node:20-slim as builder +WORKDIR /app +COPY package*.json ./ RUN npm install +COPY . . RUN npm run build + +# 실행 스테이지 +FROM node:20-slim +WORKDIR /var/app +COPY package*.json ./ +RUN npm install --only=production +COPY --from=builder /app/dist ./dist + EXPOSE 3000 -CMD [ "node", "dist/main.js" ] \ No newline at end of file +CMD ["node", "dist/main.js"] \ No newline at end of file diff --git a/FE/Dockerfile b/FE/Dockerfile index 6773e6a4..c4389e8c 100644 --- a/FE/Dockerfile +++ b/FE/Dockerfile @@ -1,17 +1,16 @@ -FROM node:20 - -RUN mkdir -p /var/app -WORKDIR /var/app - +# 빌드 스테이지 +FROM node:20-slim as builder +WORKDIR /app COPY package*.json ./ RUN npm install - COPY . . - RUN npm run build +# 실행 스테이지 +FROM node:20-slim +WORKDIR /app RUN npm install -g serve +COPY --from=builder /app/dist ./dist EXPOSE 5173 - CMD ["serve", "-s", "dist", "-l", "5173"] \ No newline at end of file