Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RELEASE 2024/12/15 18:44:40 #564

Merged
merged 2 commits into from
Dec 15, 2024
Merged
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
84 changes: 56 additions & 28 deletions .github/workflows/cd-to-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ on:
push:
branches: [ develop ]

env:
SPRING_PROFILES_ACTIVE: dev
ECR_APP_NAME: ${{ secrets.ECR_APP_NAME }}-dev
ECR_REPO: ${{ secrets.ECR_HOST }}/${{ secrets.ECR_APP_NAME }}-dev
ECR_HOST: ${{ secrets.ECR_HOST }}

jobs:
build:
name: CD Pipeline
Expand All @@ -35,12 +41,13 @@ jobs:
- name: 'Check Java Version'
run: |
java --version
echo 'ecr repo is $ECR_REPO'

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

- name: 'Get application.yml from AWS S3'
Expand All @@ -54,37 +61,58 @@ jobs:
aws s3 cp \
--region ap-northeast-2 \
s3://sopt-makers-internal/dev/deploy/${{ secrets.APPLE_KEY }} src/main/resources/static/${{ secrets.APPLE_KEY }}

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

- name: Build with Gradle
run: ./gradlew clean build -x test
- name: 'Build with Gradle'
run: |
chmod +x ./gradlew
./gradlew clean build -x test
shell: bash

- name: Get current time
- name: 'Login to ECR'
run: |
aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin $ECR_HOST

- name: 'Docker Image Build & Push'
run: |
docker build -t $ECR_APP_NAME .
docker tag $ECR_APP_NAME:latest $ECR_REPO
docker push $ECR_REPO

- name: 'Send docker-compose.yml to EC2 Instance'
uses: appleboy/scp-action@master
with:
host: ${{ secrets.DEV_RELEASE_SERVER_IP }}
username: ${{ secrets.RELEASE_SERVER_USER }}
key: ${{ secrets.DEV_RELEASE_SERVER_KEY }}
source: "./docker-compose.yml"
target: "/home/ec2-user/app/"

- name: 'Send deploy script to EC2 Instance'
uses: appleboy/scp-action@master
with:
host: ${{ secrets.DEV_RELEASE_SERVER_IP }}
username: ${{ secrets.RELEASE_SERVER_USER }}
key: ${{ secrets.DEV_RELEASE_SERVER_KEY }}
source: "./scripts/"
target: "/home/ec2-user/app/"

- name: 'Get current time'
uses: 1466587594/get-current-time@v2
id: current-time
with:
format: YYYY-MM-DDTHH-mm-ss
utcOffset: "+09:00"

- name: Spring Boot env setting
run: sudo sed -i 's/-Dspring.profiles.active=dev/-Dspring.profiles.active=dev/g' ./aws/start.sh

- name: Check env profile
run: cat ./aws/start.sh
- name: 'Docker Container Run'
uses: appleboy/ssh-action@master

- name: Make zip file
run: zip -qq -r ./$GITHUB_SHA.zip .
shell: bash

- name: Upload to S3
run: aws s3 cp --region ap-northeast-2 ./$GITHUB_SHA.zip s3://sopt-makers-internal/dev/deploy/jar/$GITHUB_SHA.zip

- name: Code Deploy
run: aws deploy create-deployment --application-name internal
--deployment-config-name CodeDeployDefault.OneAtATime
--deployment-group-name dev
--s3-location bucket=sopt-makers-internal,bundleType=zip,key=dev/deploy/jar/$GITHUB_SHA.zip
with:
host: ${{ secrets.DEV_RELEASE_SERVER_IP }}
username: ${{ secrets.RELEASE_SERVER_USER }}
key: ${{ secrets.DEV_RELEASE_SERVER_KEY }}
script: |
cd ~
sudo docker pull $ECR_REPO
sudo chmod +x ./app/scripts/*.sh
./app/scripts/deploy.sh
docker image prune -f
81 changes: 54 additions & 27 deletions .github/workflows/cd-to-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ on:
push:
branches: [ main ]

env:
SPRING_PROFILES_ACTIVE: prod
ECR_APP_NAME: ${{ secrets.ECR_APP_NAME }}-prod
ECR_REPO: ${{ secrets.ECR_HOST }}/${{ secrets.ECR_APP_NAME }}-prod
ECR_HOST: ${{ secrets.ECR_HOST }}

jobs:
build:
name: CD Pipeline
Expand All @@ -36,11 +42,11 @@ jobs:
run: |
java --version

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

- name: 'Get application.yml from AWS S3'
Expand All @@ -55,36 +61,57 @@ jobs:
--region ap-northeast-2 \
s3://sopt-makers-internal/prod/deploy/${{ secrets.APPLE_KEY }} src/main/resources/static/${{ secrets.APPLE_KEY }}

- name: Grant execute permission for gradlew
run: chmod +x ./gradlew
- name: 'Build with Gradle'
run: |
chmod +x ./gradlew
./gradlew clean build -x test
shell: bash

- name: Build with Gradle
run: ./gradlew clean build -x test
shell: bash
- name: 'Login to ECR'
run: |
aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin $ECR_HOST

- name: 'Docker Image Build & Push'
run: |
docker build -t $ECR_APP_NAME .
docker tag $ECR_APP_NAME:latest $ECR_REPO
docker push $ECR_REPO

- name: 'Send docker-compose.yml to EC2 Instance'
uses: appleboy/scp-action@master
with:
host: ${{ secrets.PROD_RELEASE_SERVER_IP }}
username: ${{ secrets.RELEASE_SERVER_USER }}
key: ${{ secrets.PROD_RELEASE_SERVER_KEY }}
source: "./docker-compose.yml"
target: "/home/ec2-user/app/"

- name: 'Send deploy script to EC2 Instance'
uses: appleboy/scp-action@master
with:
host: ${{ secrets.PROD_RELEASE_SERVER_IP }}
username: ${{ secrets.RELEASE_SERVER_USER }}
key: ${{ secrets.PROD_RELEASE_SERVER_KEY }}
source: "./scripts/"
target: "/home/ec2-user/app/"

- name: Get current time
- name: 'Get current time'
uses: 1466587594/get-current-time@v2
id: current-time
with:
format: YYYY-MM-DDTHH-mm-ss
utcOffset: "+09:00"

- name: Spring Boot env setting
run: sudo sed -i 's/-Dspring.profiles.active=dev/-Dspring.profiles.active=prod/g' ./aws/start.sh
- name: 'Docker Container Run'
uses: appleboy/ssh-action@master

- name: Check env profile
run: cat ./aws/start.sh

- name: Make zip file
run: zip -qq -r ./$GITHUB_SHA.zip .
shell: bash

- name: Upload to S3
run: aws s3 cp --region ap-northeast-2 ./$GITHUB_SHA.zip s3://sopt-makers-internal/prod/deploy/jar/$GITHUB_SHA.zip

- name: Code Deploy
run: aws deploy create-deployment --application-name internal
--deployment-config-name CodeDeployDefault.OneAtATime
--deployment-group-name prod
--s3-location bucket=sopt-makers-internal,bundleType=zip,key=prod/deploy/jar/$GITHUB_SHA.zip
with:
host: ${{ secrets.PROD_RELEASE_SERVER_IP }}
username: ${{ secrets.RELEASE_SERVER_USER }}
key: ${{ secrets.PROD_RELEASE_SERVER_KEY }}
script: |
cd ~
sudo docker pull $ECR_REPO
sudo chmod +x ./app/scripts/*.sh
./app/scripts/deploy.sh
docker image prune -f
5 changes: 3 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ jobs:

steps:
- name: 'Checkout'
uses: actions/checkout@v2
uses: actions/checkout@v3

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

- name: 'Grant execute permission for gradlew'
Expand Down
7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM amazoncorretto:17
WORKDIR /app
COPY ./build/libs/internal-0.0.1-SNAPSHOT.jar /app/APPLICATION.jar

ENV SPRING_PROFILES_ACTIVE=dev

CMD ["java", "-Duser.timezone=Asia/Seoul", "-jar", "-Dspring.profiles.active=${SPRING_PROFILES_ACTIVE}", "APPLICATION.jar"]
19 changes: 0 additions & 19 deletions appspec.yml

This file was deleted.

8 changes: 0 additions & 8 deletions aws/start.sh

This file was deleted.

3 changes: 0 additions & 3 deletions aws/stop.sh

This file was deleted.

17 changes: 0 additions & 17 deletions aws/valid.sh

This file was deleted.

21 changes: 21 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
version: '3.8'
services:
playground-blue:
image: ${ECR_REPO}
expose:
- 8080
ports:
- "8080:8080"
environment:
- TZ=Asia/Seoul
- SPRING_PROFILES_ACTIVE=${SPRING_PROFILES_ACTIVE}

playground-green:
image: ${ECR_REPO}
expose:
- 8080
ports:
- "8081:8080"
environment:
- TZ=Asia/Seoul
- SPRING_PROFILES_ACTIVE=${SPRING_PROFILES_ACTIVE}
Loading
Loading