Skip to content

Commit c3d7bd0

Browse files
authored
[25.01.01 / TASK-80] Feature - deploy 세팅 (#11)
* feature: deploy 세팅 * modify: pm2 설정 조금 업데이트, tsconfig 주석 안따라오게 업데이트
1 parent 4f759ee commit c3d7bd0

10 files changed

+177
-79
lines changed

.dockerignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
node_modules
3+
.git
4+
.env
5+
dist

Dockerfile

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# ========================================== #
2+
# Build stage
3+
# ========================================== #
4+
FROM node:23-alpine AS builder
5+
6+
WORKDIR /usr/src/app
7+
8+
# pnpm 설치
9+
RUN npm install -g pnpm
10+
11+
# 빌드에 필요한 파일만 복사
12+
COPY package.json pnpm-lock.yaml ./
13+
14+
# 의존성 설치
15+
RUN pnpm install --frozen-lockfile
16+
17+
# 소스 코드 복사 및 빌드
18+
COPY . .
19+
RUN pnpm run build
20+
21+
# ========================================== #
22+
# Production stage
23+
# ========================================== #
24+
FROM node:23-alpine
25+
26+
WORKDIR /usr/src/app
27+
28+
RUN npm install -g pnpm pm2
29+
30+
# 프로덕션 의존성만 설치
31+
COPY package.json pnpm-lock.yaml ./
32+
RUN pnpm install --prod --frozen-lockfile
33+
34+
# 빌드 결과물과 PM2 설정 파일 복사
35+
COPY --from=builder /usr/src/app/dist ./dist
36+
COPY ecosystem.config.js .
37+
38+
EXPOSE 3000
39+
40+
CMD ["pm2-runtime", "start", "ecosystem.config.js"]

docker-compose.yml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# docker-compose.yml
2+
version: '3.9'
3+
4+
services:
5+
app:
6+
build:
7+
context: .
8+
dockerfile: Dockerfile
9+
container_name: velog-dashboard-v2-api
10+
ports:
11+
- "8080:8080"
12+
env_file:
13+
- .env
14+
environment:
15+
NODE_ENV: production
16+
restart: unless-stopped

ecosystem.config.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
module.exports = {
2+
apps: [
3+
{
4+
name: 'velog-dashboard-v2-api',
5+
script: 'dist/index.js', // 빌드된 메인 파일 경로
6+
instances: 1,
7+
autorestart: true,
8+
watch: false,
9+
max_memory_restart: '1G',
10+
env: {
11+
NODE_ENV: 'production',
12+
},
13+
error_file: 'logs/err.log',
14+
out_file: 'logs/out.log',
15+
restart_delay: 4000,
16+
},
17+
],
18+
};

package.json

+6-5
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
"version": "1.0.0",
44
"description": "",
55
"main": "index.js",
6-
"type": "module",
76
"scripts": {
87
"dev": "tsx watch src/index.ts",
9-
"build": "tsc --build",
8+
"build": "tsc",
109
"lint": "eslint src/**/*.ts",
1110
"lint:fix": "eslint src/ --fix",
1211
"format": "prettier --write src/**/*.ts",
1312
"test": "jest",
1413
"test:watch": "jest --watch",
15-
"test:coverage": "jest --coverage"
14+
"test:coverage": "jest --coverage",
15+
"start": "node dist/index.js"
1616
},
1717
"lint-staged": {
1818
"*.{ts,tsx}": [
@@ -55,7 +55,8 @@
5555
"prettier": "^3.3.3",
5656
"ts-jest": "^29.2.5",
5757
"tsx": "^4.19.2",
58-
"typescript": "^5.6.3",
59-
"typescript-eslint": "^8.15.0"
58+
"typescript": "^5.7.2",
59+
"typescript-eslint": "^8.15.0",
60+
"typescript-transform-paths": "^3.5.3"
6061
}
6162
}

0 commit comments

Comments
 (0)