diff --git a/appspec.yml b/appspec.yml new file mode 100644 index 0000000..1b49066 --- /dev/null +++ b/appspec.yml @@ -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 diff --git a/buildspec.yml b/buildspec.yml new file mode 100644 index 0000000..9744b56 --- /dev/null +++ b/buildspec.yml @@ -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/**/*" \ No newline at end of file diff --git a/cd/healthCheck.sh b/cd/healthCheck.sh new file mode 100755 index 0000000..4a85572 --- /dev/null +++ b/cd/healthCheck.sh @@ -0,0 +1,2 @@ +echo "Health Check... connect to localhost:3000" +curl "http://localhost:3000" \ No newline at end of file diff --git a/cd/initialize.sh b/cd/initialize.sh new file mode 100644 index 0000000..c4cc9e5 --- /dev/null +++ b/cd/initialize.sh @@ -0,0 +1 @@ +if [ -d "/home/ubuntu/api" ]; then rm -Rf "/home/ubuntu/api"; fi \ No newline at end of file diff --git a/cd/start.sh b/cd/start.sh new file mode 100644 index 0000000..c199bac --- /dev/null +++ b/cd/start.sh @@ -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