Skip to content

Commit

Permalink
Fix: gradle.yml 수정
Browse files Browse the repository at this point in the history
- 더 이상 사용하지 않을 스크립트 파일 삭제
- appspec.yml 수정
  • Loading branch information
mjttong committed Aug 14, 2024
1 parent 77dcba6 commit 50dc5d1
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 32 deletions.
50 changes: 29 additions & 21 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ jobs:
${{ runner.os }}-gradle-
- name: Grant execute permission for gradlew
run:
chmod +x gradlew
run: chmod +x gradlew

## create application-prod.yml
- name: create application.yml
Expand All @@ -48,22 +47,6 @@ jobs:
- name: Build with Gradle
run: ./gradlew build -x test

## docker build & push to production
- name: Build Docker image
run: docker build --tag acchotsix/acc-hotsix:latest .

- name: Log in to DockerHub
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Push image to DockerHub
run: docker push acchotsix/acc-hotsix:latest

- name: Make zip file
run: zip -r ./hotsix.zip .

## deploy to production
- name: Configure AWS IAM credentials
uses: aws-actions/configure-aws-credentials@v1
Expand All @@ -72,12 +55,37 @@ jobs:
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }}
aws-region: ap-northeast-2

- name: Login to ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1

## docker build
- name: build docker file and setting deploy files
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: acc6-ecr
IMAGE_TAG: ${{ github.sha }}
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
mkdir scripts
touch scripts/deploy.sh
echo "aws ecr get-login-password --region ap-northeast-2 | docker login --username AWS --password-stdin $ECR_REGISTRY" >> scripts/deploy.sh
echo "docker pull $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> scripts/deploy.sh
echo "docker run -p 8080:8080 -e PROFILE=dev -d --restart always --name csbroker-api $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> scripts/deploy.sh
- name: Upload to S3
run: aws s3 cp --region ap-northeast-2 ./hotsix.zip s3://acc6-s3-dev-an2/hotsix.zip #버킷에 업로드.
env:
IMAGE_TAG: ${{ github.sha }}
run: |
zip -r deploy-$IMAGE_TAG.zip ./scripts appspec.yml
aws s3 cp --region ap-northeast-2 --acl private ./deploy-$IMAGE_TAG.zip s3://acc6-s3-dev-an2
- name: Start CodeDeploy Agent
run: >
env:
IMAGE_TAG: ${{ github.sha }}
run: |
aws deploy create-deployment --application-name hotsix
--deployment-config-name CodeDeployDefault.AllAtOnce
--deployment-group-name deploy-group
--s3-location bucket=acc6-s3-dev-an2,bundleType=zip,key=hotsix.zip
--s3-location bucket=acc6-s3-dev-an2,bundleType=zip,key=deploy-$IMAGE_TAG.zip
17 changes: 9 additions & 8 deletions appspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@ version: 0.0
os: linux
files:
- source: /
destination: /home/ubuntu
destination: /home/ubuntu/app
overwrite: yes

permissions:
- object: /home/ubuntu
- object: /
pattern: "**"
owner: root
group: root
owner: ubuntu
group: ubuntu
mode: 755

hooks:
ApplicationStart:
- location: scripts/run_docker.sh
timeout: 120
runas: root
AfterInstall:
- location: scripts/deploy.sh
timeout: 60
runas: ubuntu
3 changes: 0 additions & 3 deletions scripts/run_docker.sh

This file was deleted.

0 comments on commit 50dc5d1

Please sign in to comment.