Skip to content

Commit

Permalink
Merge pull request #310 from Kernel360/develop
Browse files Browse the repository at this point in the history
Main 브랜치 최신화 (24.03.18) (2)
  • Loading branch information
linglong67 authored Mar 18, 2024
2 parents 1d45bd6 + bb78a12 commit d701b6c
Show file tree
Hide file tree
Showing 20 changed files with 108 additions and 14 deletions.
37 changes: 25 additions & 12 deletions .github/workflows/cicd-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:

- name: Replace SQL Queries
run: |
dir_path="./module-api/src/main/resources/db/migration"
dir_path="./module-domain/src/main/resources/db/migration"
old_text="changeRequired"
new_text="${{ secrets.PUBLIC_KEY }}"
find "$dir_path" -type f -name "*.sql" -exec sed -i "s|$old_text|$new_text|g" {} +
Expand Down Expand Up @@ -83,23 +83,36 @@ jobs:
chmod +x ./gradlew
./gradlew bootJar
- name: DockerHub Login
uses: docker/login-action@v2
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ap-northeast-2

- name: Docker Image Build And Push (api)
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2

- name: Build, tag, and push docker image to Amazon ECR (api)
working-directory: ./module-api
env:
REGISTRY: ${{ steps.login-ecr.outputs.registry }}
REPOSITORY: dev-washfit-api
IMAGE_TAG: latest
run: |
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.MODULE_API_NAME }} . --platform=linux/amd64
docker push ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.MODULE_API_NAME }}
docker build -t $REGISTRY/$REPOSITORY:$IMAGE_TAG .
docker push $REGISTRY/$REPOSITORY:$IMAGE_TAG
- name: Docker Image Build And Push (batch)
- name: Build, tag, and push docker image to Amazon ECR (batch)
working-directory: ./module-batch
env:
REGISTRY: ${{ steps.login-ecr.outputs.registry }}
REPOSITORY: dev-washfit-batch
IMAGE_TAG: latest
run: |
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.MODULE_BATCH_NAME }} . --platform=linux/amd64
docker push ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.MODULE_BATCH_NAME }}
docker build -t $REGISTRY/$REPOSITORY:$IMAGE_TAG .
docker push $REGISTRY/$REPOSITORY:$IMAGE_TAG
- name: Application Run
uses: appleboy/[email protected]
Expand All @@ -123,7 +136,7 @@ jobs:
echo "${{ secrets.DEV_REDIS_CONF }}" > ./redis/redis.conf
echo "${{ secrets.DOCKER_COMPOSE }}" > docker-compose.yml
echo ${{ secrets.DOCKERHUB_PASSWORD }} | docker login --username ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
aws ecr get-login-password --region ap-northeast-2 | docker login --username AWS --password-stdin ${{ steps.login-ecr.outputs.registry }}
docker image prune -af
Expand Down
38 changes: 36 additions & 2 deletions .github/workflows/cicd-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:

- name: Replace SQL Queries
run: |
dir_path="./module-api/src/main/resources/db/migration"
dir_path="./module-domain/src/main/resources/db/migration"
old_text="changeRequired"
new_text="${{ secrets.PUBLIC_KEY }}"
find "$dir_path" -type f -name "*.sql" -exec sed -i "s|$old_text|$new_text|g" {} +
Expand All @@ -35,6 +35,13 @@ jobs:
env:
spring.profiles.active: "prod"

- name: Set application yml file (batch)
uses: microsoft/variable-substitution@v1
with:
files: ./module-batch/src/main/resources/application.yml
env:
spring.profiles.active: "prod"

- name: Set application-prod yml file (api)
uses: microsoft/variable-substitution@v1
with:
Expand All @@ -53,12 +60,29 @@ jobs:
aws.s3.bucket.name: ${{ secrets.AWS_S3_BUCKET_NAME }}
aws.s3.bucket.url: ${{ secrets.AWS_S3_BUCKET_URL }}

- name: Set application-dev yml file (batch)
uses: microsoft/variable-substitution@v1
with:
files: ./module-batch/src/main/resources/application-prod.yml
env:
spring.datasource.url: ${{ secrets.DB_URL_AWS }}
spring.datasource.username: ${{ secrets.DB_USER }}
spring.datasource.password: ${{ secrets.DB_PW }}
external.ecolife-api.path: ${{ secrets.ECOLIFE_PATH }}
external.ecolife-api.service-key: ${{ secrets.ECOLIFE_KEY }}

- name: Grant execute permission And Build with Gradle (api)
working-directory: ./module-api
run: |
chmod +x ./gradlew
./gradlew bootJar
- name: Grant execute permission And Build with Gradle (batch)
working-directory: ./module-batch
run: |
chmod +x ./gradlew
./gradlew bootJar
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v3
with:
Expand All @@ -70,7 +94,7 @@ jobs:
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2

- name: Build, tag, and push docker image to Amazon ECR
- name: Build, tag, and push docker image to Amazon ECR (api)
working-directory: ./module-api
env:
REGISTRY: ${{ steps.login-ecr.outputs.registry }}
Expand All @@ -80,6 +104,16 @@ jobs:
docker build -t $REGISTRY/$REPOSITORY:$IMAGE_TAG .
docker push $REGISTRY/$REPOSITORY:$IMAGE_TAG
- name: Build, tag, and push docker image to Amazon ECR (batch)
working-directory: ./module-batch
env:
REGISTRY: ${{ steps.login-ecr.outputs.registry }}
REPOSITORY: washfit-batch
IMAGE_TAG: latest
run: |
docker build -t $REGISTRY/$REPOSITORY:$IMAGE_TAG .
docker push $REGISTRY/$REPOSITORY:$IMAGE_TAG
- name: Application Run
uses: appleboy/[email protected]
with:
Expand Down
47 changes: 47 additions & 0 deletions module-batch/src/main/resources/application-prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
spring:
jpa:
hibernate:
ddl-auto: validate
show-sql: true
properties:
hibernate:
generate_statistics: true
jdbc:
batch_size: 100
format_sql: true
open-in-view: true

datasource:
driver-class-name: org.postgresql.Driver
url: ${DB_URL_AWS}
username: ${DB_USER}
password: ${DB_PW}
hikari:
maximum-pool-size: 100
idle-timeout: 20000
validation-timeout: 5000
minimum-idle: 5

external:
ecolife-api:
path: ${ECOLIFE_PATH}
service-key: ${ECOLIFE_KEY}


logging:
file:
path: ./logs/batch/
name: batch-log
logback:
rolling policy:
max-history: 14
max-file-size: 50MB
total-size-cap: 5GB
level:
root: warn
com.kernel360: debug
org.hibernate.sql: debug
org.hibernate.type.descriptor.sql: trace
org:
springframework:
transaction=DEBUG:

0 comments on commit d701b6c

Please sign in to comment.