diff --git a/backend-node/Dockerfile b/backend-node/Dockerfile new file mode 100644 index 00000000..247bab22 --- /dev/null +++ b/backend-node/Dockerfile @@ -0,0 +1,51 @@ +# syntax=docker/dockerfile:1 + +# Base image (Debian-based for glibc + OpenSSL compatibility) +FROM node:20-bookworm-slim AS base +WORKDIR /app +ENV NODE_ENV=production +# Install OpenSSL and required certs +RUN apt-get update \ + && apt-get install -y --no-install-recommends openssl ca-certificates \ + && rm -rf /var/lib/apt/lists/* + +# Dependencies stage (install deps and generate Prisma client) +FROM base AS deps +COPY package*.json ./ +RUN npm ci --omit=dev && npm cache clean --force +# Copy prisma schema and generate client (glibc target will be detected) +COPY prisma ./prisma +ENV PRISMA_SKIP_POSTINSTALL_GENERATE=true +RUN npx prisma generate + +# Build stage (compile TypeScript) +FROM node:20-bookworm-slim AS build +WORKDIR /app +COPY package*.json ./ +RUN npm ci && npm cache clean --force +COPY tsconfig.json ./ +COPY src ./src +RUN npm run build + +# Runtime image +FROM node:20-bookworm-slim AS runner +WORKDIR /app +ENV NODE_ENV=production +# Ensure OpenSSL present +RUN apt-get update \ + && apt-get install -y --no-install-recommends openssl ca-certificates \ + && rm -rf /var/lib/apt/lists/* + +# Create non-root user +RUN groupadd -r appgroup && useradd -r -g appgroup appuser + +# Copy node_modules with generated Prisma client +COPY --from=deps /app/node_modules ./node_modules +# Copy built files +COPY --from=build /app/dist ./dist +# Copy package files +COPY package*.json ./ + +EXPOSE 8080 +USER appuser +CMD ["node", "dist/app.js"] diff --git a/backend-node/prisma/schema.prisma b/backend-node/prisma/schema.prisma index 6467cb73..abef7b29 100644 --- a/backend-node/prisma/schema.prisma +++ b/backend-node/prisma/schema.prisma @@ -1,5 +1,6 @@ generator client { - provider = "prisma-client-js" + provider = "prisma-client-js" + binaryTargets = ["native", "linux-arm64-openssl-3.0.x"] } datasource db { @@ -775,7 +776,6 @@ model company_mng { regdate DateTime? @db.Timestamp(6) status String? @db.VarChar(32) } - /// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments model contract_mgmt { objid String @id @db.VarChar @@ -1576,7 +1576,6 @@ model invoice_mgmt { discount_percentage String? @db.VarChar inv_discount_price String? @db.VarChar } - model invoice_mgmt_part { objid String @id @db.VarChar invoice_objid String? @db.VarChar @@ -2354,7 +2353,6 @@ model part_mng { @@index([part_no]) } - /// The underlying table does not contain a valid unique identifier and can therefore currently not be handled by Prisma Client. model part_mng_del { objid String? @db.VarChar @@ -3148,7 +3146,6 @@ model product_group_mng { @@ignore } - /// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments model product_kind_spec { objid String @db.VarChar @@ -3924,7 +3921,6 @@ model purchase_order_master_240402 { @@ignore } - /// The underlying table does not contain a valid unique identifier and can therefore currently not be handled by Prisma Client. model purchase_order_master_240509 { objid String? @db.VarChar @@ -4707,7 +4703,6 @@ model sales_bom_report_part { @@index([parent_objid]) } - /// The underlying table does not contain a valid unique identifier and can therefore currently not be handled by Prisma Client. model sales_bom_report_part_240422 { objid String? @db.VarChar @@ -4991,7 +4986,7 @@ model setup_wbs_task { /// The underlying table does not contain a valid unique identifier and can therefore currently not be handled by Prisma Client. model setup_wbs_task_standard { - objid String? @unique(map: "setup_wbs_task_standard _objid_key") @db.VarChar + objid String? @unique(map: "setup_wbs_task_standard_objid_key") @db.VarChar contract_objid String? @db.VarChar parent_objid String? @db.VarChar task_category String? @db.VarChar @@ -5494,7 +5489,6 @@ model swpc120a_tbl { @@id([imitemid, suvndcd], map: "pk_swpc120a_tbl") } - model swpc130a_tbl { imitemid String @db.VarChar(15) suvndcd String @db.VarChar(5) @@ -6254,7 +6248,6 @@ model swsb500a_tbl { edit_date DateTime? @db.Timestamp(6) edit_emp String? @db.VarChar(30) } - model swsb510a_tbl { frw_req_no String @id(map: "pk_swsb510a_tbl") @db.VarChar(10) req_date String? @db.VarChar(8) @@ -6842,4 +6835,4 @@ model zz_230410_user_info { fax_no String? @db.VarChar @@ignore -} +} \ No newline at end of file diff --git a/docker-compose.backend.linux.yml b/docker-compose.backend.linux.yml index 1304101d..39bdacb1 100644 --- a/docker-compose.backend.linux.yml +++ b/docker-compose.backend.linux.yml @@ -1,29 +1,31 @@ -version: '3.8' +version: "3.8" services: - # Spring Boot 백엔드만 + # Node.js 백엔드 backend: build: - context: ./backend + context: ./backend-node dockerfile: Dockerfile container_name: pms-backend-linux ports: - "8080:8080" environment: - - SPRING_PROFILES_ACTIVE=dev - - SPRING_DATASOURCE_URL=jdbc:postgresql://39.117.244.52:11132/plm?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Seoul - - SPRING_DATASOURCE_USERNAME=postgres - - SPRING_DATASOURCE_PASSWORD=ph0909!! - - LANG=ko_KR.UTF-8 - - LANGUAGE=ko_KR:ko - - LC_ALL=ko_KR.UTF-8 - - TZ=Asia/Seoul - - JAVA_OPTS=-Xms512m -Xmx1024m -Dfile.encoding=UTF-8 -Duser.timezone=Asia/Seoul -Djava.awt.headless=true + - NODE_ENV=development + - PORT=8080 + - DATABASE_URL=postgresql://postgres:ph0909!!@39.117.244.52:11132/plm + - JWT_SECRET=ilshin-plm-super-secret-jwt-key-2024 + - JWT_EXPIRES_IN=24h + - CORS_ORIGIN=http://localhost:9771 + - CORS_CREDENTIALS=true + - LOG_LEVEL=debug + volumes: + - ./backend-node:/app + - /app/node_modules networks: - pms-network restart: unless-stopped healthcheck: - test: ["CMD", "curl", "-f", "http://localhost:8080/api/actuator/health"] + test: ["CMD", "curl", "-f", "http://localhost:8080/health"] interval: 30s timeout: 10s retries: 3 @@ -31,4 +33,4 @@ services: networks: pms-network: - driver: bridge \ No newline at end of file + driver: bridge diff --git a/docker-compose.backend.mac.yml b/docker-compose.backend.mac.yml index 3a618cbb..76eb4b9c 100644 --- a/docker-compose.backend.mac.yml +++ b/docker-compose.backend.mac.yml @@ -1,29 +1,31 @@ -version: '3.8' +version: "3.8" services: - # Spring Boot 백엔드만 + # Node.js 백엔드 backend: build: - context: ./backend - dockerfile: Dockerfile.mac + context: ./backend-node + dockerfile: Dockerfile container_name: pms-backend-mac ports: - "8080:8080" environment: - - SPRING_PROFILES_ACTIVE=dev - - SPRING_DATASOURCE_URL=jdbc:postgresql://39.117.244.52:11132/plm?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Seoul - - SPRING_DATASOURCE_USERNAME=postgres - - SPRING_DATASOURCE_PASSWORD=ph0909!! - - LANG=ko_KR.UTF-8 - - LANGUAGE=ko_KR:ko - - LC_ALL=ko_KR.UTF-8 - - TZ=Asia/Seoul - - JAVA_OPTS=-Xms512m -Xmx1024m -Dfile.encoding=UTF-8 -Duser.timezone=Asia/Seoul -Djava.awt.headless=true + - NODE_ENV=development + - PORT=8080 + - DATABASE_URL=postgresql://postgres:ph0909!!@39.117.244.52:11132/plm + - JWT_SECRET=ilshin-plm-super-secret-jwt-key-2024 + - JWT_EXPIRES_IN=24h + - CORS_ORIGIN=http://localhost:9771 + - CORS_CREDENTIALS=true + - LOG_LEVEL=debug + volumes: + - ./backend-node:/app + - /app/node_modules networks: - pms-network restart: unless-stopped healthcheck: - test: ["CMD", "curl", "-f", "http://localhost:8080/api/actuator/health"] + test: ["CMD", "curl", "-f", "http://localhost:8080/health"] interval: 30s timeout: 10s retries: 3 @@ -31,4 +33,4 @@ services: networks: pms-network: - driver: bridge \ No newline at end of file + driver: bridge diff --git a/docker-compose.backend.win.yml b/docker-compose.backend.win.yml index 5828f975..67557614 100644 --- a/docker-compose.backend.win.yml +++ b/docker-compose.backend.win.yml @@ -1,29 +1,31 @@ version: "3.8" services: - # Spring Boot 백엔드만 + # Node.js 백엔드 backend: build: - context: ./backend - dockerfile: Dockerfile.mac + context: ./backend-node + dockerfile: Dockerfile container_name: pms-backend-win ports: - "8080:8080" environment: - - SPRING_PROFILES_ACTIVE=dev - - SPRING_DATASOURCE_URL=jdbc:postgresql://39.117.244.52:11132/plm?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Seoul - - SPRING_DATASOURCE_USERNAME=postgres - - SPRING_DATASOURCE_PASSWORD=ph0909!! - - LANG=ko_KR.UTF-8 - - LANGUAGE=ko_KR:ko - - LC_ALL=ko_KR.UTF-8 - - TZ=Asia/Seoul - - JAVA_OPTS=-Xms512m -Xmx1024m -Dfile.encoding=UTF-8 -Duser.timezone=Asia/Seoul -Djava.awt.headless=true + - NODE_ENV=development + - PORT=8080 + - DATABASE_URL=postgresql://postgres:ph0909!!@39.117.244.52:11132/plm + - JWT_SECRET=ilshin-plm-super-secret-jwt-key-2024 + - JWT_EXPIRES_IN=24h + - CORS_ORIGIN=http://localhost:9771 + - CORS_CREDENTIALS=true + - LOG_LEVEL=debug + volumes: + - ./backend-node:/app + - /app/node_modules networks: - pms-network restart: unless-stopped healthcheck: - test: ["CMD", "curl", "-f", "http://localhost:8080/api/actuator/health"] + test: ["CMD", "curl", "-f", "http://localhost:8080/health"] interval: 30s timeout: 10s retries: 3 diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 00000000..628432bf --- /dev/null +++ b/package-lock.json @@ -0,0 +1,6 @@ +{ + "name": "ERP-node", + "lockfileVersion": 3, + "requires": true, + "packages": {} +} diff --git a/start-all-separated.sh b/start-all-separated.sh old mode 100644 new mode 100755 index fc78f3a6..b01ef6fb --- a/start-all-separated.sh +++ b/start-all-separated.sh @@ -5,12 +5,12 @@ echo "PLM 솔루션 - 전체 서비스 시작 (분리형)" echo "============================================" echo "" -echo "🚀 백엔드와 프론트엔드를 순차적으로 시작합니다..." +echo "🚀 백엔드(Node.js)와 프론트엔드(Next.js)를 순차적으로 시작합니다..." echo "" # 백엔드 먼저 시작 echo "============================================" -echo "1. 백엔드 서비스 시작 중..." +echo "1. 백엔드 서비스 시작 중... (Node.js)" echo "============================================" docker-compose -f docker-compose.backend.mac.yml build --no-cache @@ -25,7 +25,7 @@ sleep 20 # 프론트엔드 시작 echo "" echo "============================================" -echo "2. 프론트엔드 서비스 시작 중..." +echo "2. 프론트엔드 서비스 시작 중... (Next.js)" echo "============================================" docker-compose -f docker-compose.frontend.mac.yml build --no-cache @@ -42,7 +42,7 @@ echo "🎉 모든 서비스가 시작되었습니다!" echo "============================================" echo "" echo "[DATABASE] PostgreSQL: http://39.117.244.52:11132" -echo "[BACKEND] Spring Boot: http://localhost:8080/api" +echo "[BACKEND] Node.js API: http://localhost:8080/api" echo "[FRONTEND] Next.js: http://localhost:9771" echo "" echo "서비스 상태 확인:" diff --git a/start-frontend.sh b/start-frontend.sh old mode 100644 new mode 100755