Skip to content

Commit

Permalink
Merge pull request #45 from SUIN-BUNDANG-LINE/SBL-115-cicd-bash
Browse files Browse the repository at this point in the history
[SBL-115] cicd bash
  • Loading branch information
GulSauce authored Sep 4, 2024
2 parents 8624b84 + d62b915 commit 93aa329
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 26 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/prod_deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh
# ubuntu 권한으로 모든 명령어 실행
sudo -u ubuntu sh <<EOF
cd ~/Frontend
git checkout main
git pull
echo "$ENV_CONTENT" | base64 -d > .env.local
npm install
npm run build
pm2 start pm2.config.js
EOF
10 changes: 1 addition & 9 deletions .github/workflows/prod_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ jobs:
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ap-northeast-2
EC2_INSTANCE_ID: ${{ secrets.FRONTEND_EC2_INSTANCE_ID }}
# Docker 관련
CONTAINER_NAME: sulmun2yong-production-client
# Next.js 관련
ENV_CONTENT: ${{ secrets.FRONTEND_PRODUCTION_ENV_CONTENT }}

Expand All @@ -36,10 +34,4 @@ jobs:
--document-name "AWS-RunShellScript" \
--targets "Key=instanceIds, Values=${{ env.EC2_INSTANCE_ID}}" \
--parameters '{"workingDirectory": ["/home/ubuntu/Frontend"],
"commands" : ["git pull origin main",
"echo \"${{ env.ENV_CONTENT }}\" | base64 -d > .env.local",
"docker stop ${{ env.CONTAINER_NAME }} || true",
"docker rm ${{ env.CONTAINER_NAME }} || true",
"docker build -t ${{ env.CONTAINER_NAME }}:latest . ",
"docker run -d -p 3000:3000 --name ${{ env.CONTAINER_NAME }} ${{ env.CONTAINER_NAME }}:latest",
"docker image prune -af"]}'
"commands" : ["ENV_CONTENT='${{ env.ENV_CONTENT }}' bash ./.github/workflows/prod_deploy.sh"]}'
17 changes: 0 additions & 17 deletions dockerfile

This file was deleted.

11 changes: 11 additions & 0 deletions pm2.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
apps: [
{
name: "sulmun2yong-production-client",
script: "./node_modules/next/dist/bin/next",
args: "start",
instances: "max",
exec_mode: "cluster"
},
],
};

0 comments on commit 93aa329

Please sign in to comment.