Skip to content

Commit

Permalink
CI/CD: EB pipeline 구축
Browse files Browse the repository at this point in the history
  • Loading branch information
yxhwxn committed Jul 17, 2024
1 parent 23e13b0 commit 40e61c1
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 113 deletions.
184 changes: 92 additions & 92 deletions .github/workflows/dev_deploy_docker_beanstalk.yml
Original file line number Diff line number Diff line change
@@ -1,92 +1,92 @@
name: suppin dev Docker Beanstalk CI/CD # Workflow 이름

on:
push:
branches:
- dev
pull_request:
branches:
- dev
types: [closed]
workflow_dispatch: # (2).수동 실행도 가능하도록

jobs:
build:
runs-on: ubuntu-latest # (3).OS환경
if: github.ref == 'refs/heads/main' || (github.event_name == 'pull_request' && github.event.pull_request.merged == true)


steps:
- name: Checkout current repository
uses: actions/checkout@v2

- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 17

- name: Grant execute permission for gradlew
run: chmod +x ./gradlew
shell: bash

- name: Build with Gradle
run: ./gradlew clean build
shell: bash

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ap-northeast-2

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

- name: Build, tag, and push image to Amazon ECR
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: tree-dev
IMAGE_TAG: latest
run: |
# Docker 이미지 빌드
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
# 빌드한 이미지를 Amazon ECR로 푸시
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
# 빌드된 이미지의 정보 출력
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
- name: Get current time
uses: 1466587594/get-current-time@v2
id: current-time
with:
format: YYYYMMDD_HH-mm-ss
utcOffset: "+09:00"

- name: Generate deployment package
run: |
mkdir -p deploy
cp -r .ebextensions deploy/.ebextensions
cp Dockerrun.aws.json deploy/Dockerrun.aws.json
cp -r .platform deploy/.platform
cd deploy && zip -r deploy.zip .
- name: Beanstalk Deploy
uses: einaregilsson/beanstalk-deploy@v14
with:
aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
application_name: suppin-dev
environment_name: suppin-dev-env
version_label: github-action-${{ steps.current-time.outputs.formattedTime }}
region: ap-northeast-2
deployment_package: deploy/deploy.zip
wait_for_deployment: false




#name: suppin dev Docker Beanstalk CI/CD # Workflow 이름
#
#on:
# push:
# branches:
# - dev
# pull_request:
# branches:
# - dev
# types: [closed]
# workflow_dispatch: # (2).수동 실행도 가능하도록
#
#jobs:
# build:
# runs-on: ubuntu-latest # (3).OS환경
# if: github.ref == 'refs/heads/main' || (github.event_name == 'pull_request' && github.event.pull_request.merged == true)
#
#
# steps:
# - name: Checkout current repository
# uses: actions/checkout@v2
#
# - name: Set up JDK 17
# uses: actions/setup-java@v1
# with:
# java-version: 17
#
# - name: Grant execute permission for gradlew
# run: chmod +x ./gradlew
# shell: bash
#
# - name: Build with Gradle
# run: ./gradlew clean build
# shell: bash
#
# - name: Configure AWS credentials
# uses: aws-actions/configure-aws-credentials@v1
# with:
# aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
# aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# aws-region: ap-northeast-2
#
# - name: Login to Amazon ECR
# id: login-ecr
# uses: aws-actions/amazon-ecr-login@v1
#
# - name: Build, tag, and push image to Amazon ECR
# id: build-image
# env:
# ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
# ECR_REPOSITORY: tree-dev
# IMAGE_TAG: latest
# run: |
# # Docker 이미지 빌드
# docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
#
# # 빌드한 이미지를 Amazon ECR로 푸시
# docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
#
# # 빌드된 이미지의 정보 출력
# echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
#
# - name: Get current time
# uses: 1466587594/get-current-time@v2
# id: current-time
# with:
# format: YYYYMMDD_HH-mm-ss
# utcOffset: "+09:00"
#
# - name: Generate deployment package
# run: |
# mkdir -p deploy
# cp -r .ebextensions deploy/.ebextensions
# cp Dockerrun.aws.json deploy/Dockerrun.aws.json
# cp -r .platform deploy/.platform
# cd deploy && zip -r deploy.zip .
#
# - name: Beanstalk Deploy
# uses: einaregilsson/beanstalk-deploy@v14
# with:
# aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }}
# aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# application_name: suppin-dev
# environment_name: suppin-dev-env
# version_label: github-action-${{ steps.current-time.outputs.formattedTime }}
# region: ap-northeast-2
# deployment_package: deploy/deploy.zip
# wait_for_deployment: false
#
#
#
#
18 changes: 9 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM adoptopenjdk:17-jdk-hotspot

ARG JAR_FILE=build/libs/*.jar

COPY ${JAR_FILE} app.jar

EXPOSE 8080

ENTRYPOINT ["java", "-jar", "/app.jar"]
#FROM adoptopenjdk:17-jdk-hotspot
#
#ARG JAR_FILE=build/libs/*.jar
#
#COPY ${JAR_FILE} app.jar
#
#EXPOSE 8080
#
#ENTRYPOINT ["java", "-jar", "/app.jar"]
24 changes: 12 additions & 12 deletions Dockerrun.aws.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"AWSEBDockerrunVersion": "1",
"Image": {
"Name": "730335324790.dkr.ecr.ap-northeast-2.amazonaws.com/suppin:latest",
"Update": "true"
},
"Ports": [
{
"ContainerPort": "8080"
}
]
}
//{
// "AWSEBDockerrunVersion": "1",
// "Image": {
// "Name": "730335324790.dkr.ecr.ap-northeast-2.amazonaws.com/suppin:latest",
// "Update": "true"
// },
// "Ports": [
// {
// "ContainerPort": "8080"
// }
// ]
//}

0 comments on commit 40e61c1

Please sign in to comment.