Skip to content

Commit

Permalink
인프라 마이그레이션 (#1636)
Browse files Browse the repository at this point in the history
* refactor: move slack uri from system environment to properties

* feat: update .gitignore to include terraform file exclusions

* feat: add terraform infrastructure and configuration updates for dev

* test: fix broken tests

* feat: upgrade gradle version from 6.8.3 to 8.10

* feat: upgrade spring to 3.4.1 and java to 21

- remove dependencies related to elasticsearch
- delete code implemented using elasticsearch
- eliminate static keyword in entity initialization
- migrate from javax to jakarta
- fix minor problematic code issues
- apply code formatting

* feat: configure application settings using aws secretsmanager

* feat: add secrets manager access role to ec2

* feat: upgrade java version from 1.8 to 21

* feat: update gitHub actions deploy scripts

* feat: update secret name

* feat: update logback configuration to new syntax

* feat: upgrade flyway version from 6.4.2 to 9.x

* feat: add environment variables for build and deploy

* fix: apply spring expression language syntax

* feat: add health check controller

* fix: remove duplicate health check controller

* fix: resolve minor deploy issue

* fix: remove unexpected character from flyway script

* fix: add command to pkill with sudo

* fix: add tf api token

* refactor: remove elastic search dependencies

* fix: change terraform name

* feat: update java version from 11 to 21

---------

Co-authored-by: woowahan-neo <[email protected]>
  • Loading branch information
jaeyeonling and woowahan-neo authored Jan 8, 2025
1 parent b8433e5 commit 95d8c1b
Show file tree
Hide file tree
Showing 413 changed files with 3,719 additions and 2,860 deletions.
64 changes: 0 additions & 64 deletions .github/workflows/back-dev.yml

This file was deleted.

64 changes: 0 additions & 64 deletions .github/workflows/back-prod.yml

This file was deleted.

74 changes: 74 additions & 0 deletions .github/workflows/back.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: back deploy

on:
workflow_dispatch:
inputs:
environment:
description: 'Target environment (dev, prod)'
required: true
default: 'dev'

jobs:
deploy:
runs-on: ubuntu-latest
environment: ${{ github.event.inputs.environment }}
services:
mysql:
image: mysql:8.0.28
env:
MYSQL_USER: user
MYSQL_PASSWORD: password
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: prolog
ports:
- 13306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3

steps:
- name: Checkout Source Code
uses: actions/checkout@v2

- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: 'corretto'
java-version: 21

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

- name: Build with Gradle
run: ./gradlew flywayClean flywayBaseline flywayMigrate bootJar -Dflyway.baselineVersion=0
shell: bash
working-directory: backend

- name: Generate deployment package
working-directory: backend
run: |
mkdir -p deploy
cp build/libs/*.jar deploy/app.jar
cp appspec.yml deploy/appspec.yml
cp -r scripts deploy/scripts
cd deploy && zip -r app.zip .
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}

- name: Upload to S3
run: |
aws s3 cp backend/deploy/app.zip s3://${{ secrets.BUCKET_NAME }}/app.zip
- name: Trigger AWS CodeDeploy
run: |
aws deploy create-deployment \
--application-name ${{ secrets.APPLICATION_NAME }} \
--deployment-group-name ${{ secrets.DEPLOYMENT_GROUP_NAME }} \
--s3-location bucket=${{ secrets.BUCKET_NAME }},key=app.zip,bundleType=zip \
--deployment-config-name CodeDeployDefault.AllAtOnce \
--auto-rollback-configuration enabled=true,events=DEPLOYMENT_FAILURE
7 changes: 4 additions & 3 deletions .github/workflows/sonar-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ jobs:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 11
uses: actions/setup-java@v1
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: 11
distribution: 'corretto'
java-version: 21
- name: Cache SonarCloud packages
uses: actions/cache@v1
with:
Expand Down
35 changes: 35 additions & 0 deletions .github/workflows/terraform.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: terraform deploy

on:
workflow_dispatch:
inputs:
environment:
description: 'Target environment (dev, prod)'
required: true
default: 'dev'

jobs:
deploy:
runs-on: ubuntu-latest
env:
TF_API_TOKEN: ${{ secrets.TF_API_TOKEN }}

steps:
- name: Checkout Source Code
uses: actions/checkout@v2

- name: Set up Terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_version: 1.5.3

- name: Select workspace
run: |
ENVIRONMENT=${{ github.event.inputs.environment }}
terraform workspace select "$ENVIRONMENT" || terraform workspace new "$ENVIRONMENT"
- name: Terraform Init and Apply
run: |
terraform init
terraform plan -out=tfplan
terraform apply tfplan
38 changes: 38 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,41 @@

### direnv ###
.envrc

# Terraform state files
*.tfstate
*.tfstate.*

# Backup files created by Terraform
*.tfstate.backup

# Crash log files
crash.log

# Terraform variable files containing sensitive data
*.tfvars
*.tfvars.json

# Terraform plan files
tfplan
*.tfplan

# Terraform override files
override.tf
override.tf.json
*_override.tf
*_override.tf.json

# Terraform provider plugins
.terraform/
.terraform.lock.hcl

# Local command logs
.terraform.rc
terraform.rc

# Deploy folder
backend/deploy

# Private key
private_key.pem
6 changes: 0 additions & 6 deletions backend/.ebextensions/01-set-timezone.config

This file was deleted.

27 changes: 0 additions & 27 deletions backend/.ebextensions/02-set-filebeat.config

This file was deleted.

27 changes: 27 additions & 0 deletions backend/appspec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
version: 0.0
os: linux

files:
- source: /app.jar
destination: /home/ec2-user/

hooks:
ApplicationStop:
- location: scripts/stop-app.sh
timeout: 300
runas: ec2-user

BeforeInstall:
- location: scripts/before-install.sh
timeout: 300
runas: ec2-user

AfterInstall:
- location: scripts/after-install.sh
timeout: 300
runas: ec2-user

ApplicationStart:
- location: scripts/start-app.sh
timeout: 300
runas: ec2-user
Loading

0 comments on commit 95d8c1b

Please sign in to comment.