Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions appspec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 0.0
os: linux
files:
- source: /
destination: /home/ubuntu/api
hooks:
ApplicationStart:
- location: /cd/start.sh
runas: ubuntu
ValidateService:
- location: /cd/healthCheck.sh
runas: ubuntu
21 changes: 21 additions & 0 deletions buildspec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
version: 0.2

phases:
install:
runtime-versions:
nodejs: 18
commands:
- npm install
- pwd
run-as: root
build:
commands:
- npx @nestjs/cli build
- rm -rf node_modules
run-as: root
artifacts:
files:
- "**/*"
cache:
paths:
- "node_modules/**/*"
2 changes: 2 additions & 0 deletions cd/healthCheck.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
echo "Health Check... connect to localhost:3000"
curl "http://localhost:3000"
1 change: 1 addition & 0 deletions cd/initialize.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
if [ -d "/home/ubuntu/api" ]; then rm -Rf "/home/ubuntu/api"; fi
9 changes: 9 additions & 0 deletions cd/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
cd /home/ubuntu/api

# 원래 node 프로세스 종료
sudo kill -9 `ps -ef | grep 'node' | awk '{print $2}'`
sudo chmod -R 777 /home/ubuntu/api
npm install
nohup cross-env NODE_ENV=dev node /home/ubuntu/api/dist/main >/home/ubuntu/log/logs 2>&1 </home/ubuntu/log/errors &
sudo rm -rf "install"
echo "done start.sh"