-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: ecs cd를 위한 구현 * chore: 오타 수정 * fix: aws 환경에 맞추어 AmazonS3Client 생성 방식 수정 * feat: logback-spring 추가 * feat: resource 라벨 설정 추가 * feat: hikari 로그 설정 추가
- Loading branch information
1 parent
d205f43
commit 571205f
Showing
5 changed files
with
178 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
name: DEV - Deploy to Amazon ECS | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
workflow_dispatch: | ||
env: | ||
AWS_REGION: ap-northeast-2 | ||
ECR_REPOSITORY: few-ecr | ||
ECS_SERVICE: few-ecs-service | ||
ECS_CLUSTER: few-ecs-cluster | ||
ECS_TASK_DEFINITION: task-definition.json | ||
TASK_DEFINITION_NAME: few-ecs-task | ||
CONTAINER_NAME: few-container | ||
|
||
jobs: | ||
build-and-push-docker-image: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
distribution: 'temurin' | ||
java-version: '17' | ||
cache: gradle | ||
|
||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v1 | ||
with: | ||
aws-access-key-id: ${{ secrets.DEV_AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.DEV_AWS_SECRET_ACCESS_KEY }} | ||
aws-region: ${{ env.AWS_REGION }} | ||
|
||
- name: Login to Amazon ECR | ||
id: login-ecr | ||
uses: aws-actions/amazon-ecr-login@v1 | ||
|
||
- name: Grant execute permission for gradlew | ||
run: chmod +x gradlew | ||
|
||
- name: Jooq Code Generation | ||
run: | | ||
./gradlew jooqCodegenAll | ||
- name: Test with Gradle | ||
run: | | ||
./gradlew test | ||
- name: Generate OpenAPI3 | ||
run: | | ||
./gradlew --info api:openapi3 -PserverUrl=https://api.fewletter.site | ||
- name: Generate Swagger | ||
run: | | ||
./gradlew --info api:generateStaticSwaggerUIApi | ||
- name: Build with Gradle bootBuildImage, tag, and push image to Amazon ECR | ||
env: | ||
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | ||
run: | | ||
GIT_HASH=$(git rev-parse --short HEAD) | ||
./gradlew buildEcsDockerImage -PimageName=${ECR_REGISTRY}/${ECR_REPOSITORY}:latest | ||
docker tag ${ECR_REGISTRY}/${ECR_REPOSITORY}:latest ${ECR_REGISTRY}/${ECR_REPOSITORY}:${GIT_HASH} | ||
docker push ${ECR_REGISTRY}/${ECR_REPOSITORY} --all-tags | ||
- name: Get ECR Repository image path | ||
id: get-docker-image-path | ||
env: | ||
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | ||
run: | | ||
GIT_HASH=$(git rev-parse --short HEAD) | ||
echo ${ECR_REGISTRY}/${ECR_REPOSITORY}:${GIT_HASH} | ||
echo "::set-output name=image::${ECR_REGISTRY}/${ECR_REPOSITORY}:${GIT_HASH}" | ||
- name: Download task definition | ||
run: | | ||
aws ecs describe-task-definition --task-definition ${TASK_DEFINITION_NAME} --query taskDefinition > task-definition.json | ||
- name: Fill in the new image ID in the Amazon ECS task definition | ||
id: task-definition | ||
uses: aws-actions/amazon-ecs-render-task-definition@v1 | ||
with: | ||
task-definition: ${{ env.ECS_TASK_DEFINITION }} | ||
container-name: ${{ env.CONTAINER_NAME }} | ||
image: ${{ steps.get-docker-image-path.outputs.image }} | ||
|
||
- name: Deploy Amazon ECS task definition | ||
id: ecs-deployment | ||
uses: aws-actions/amazon-ecs-deploy-task-definition@v1 | ||
with: | ||
task-definition: ${{ steps.task-definition.outputs.task-definition }} | ||
service: ${{ env.ECS_SERVICE }} | ||
cluster: ${{ env.ECS_CLUSTER }} | ||
wait-for-service-stability: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<configuration debug="true"> | ||
<property resource="application.yml"/> | ||
<property name="TRACE_ID_CONSOLE_PATTERN" value="%d{yyyy-MM-dd HH:mm:ss.SSS} %magenta([%thread]) %highlight([%-3level]) [%X{TraceId}] %logger{5} - %msg %n" /> | ||
<springProperty name="LOGS_ABSOLUTE_PATH" source="log.file.path"/> | ||
|
||
<include resource="org/springframework/boot/logging/logback/defaults.xml"/> | ||
|
||
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> | ||
<encoder> | ||
<pattern>${TRACE_ID_CONSOLE_PATTERN}</pattern> | ||
</encoder> | ||
</appender> | ||
|
||
<springProfile name="prd"> | ||
<root level="INFO"> | ||
<appender-ref ref="CONSOLE"/> | ||
</root> | ||
<logger name="com.few" level="DEBUG"> | ||
<appender-ref ref="CONSOLE"/> | ||
</logger> | ||
<logger name="org.jooq" level="DEBUG"> | ||
<appender-ref ref="CONSOLE"/> | ||
</logger> | ||
<logger name="com.zaxxer.hikari" level="DEBUG"> | ||
<appender-ref ref="CONSOLE"/> | ||
</logger> | ||
<logger name="org.springframework" level="INFO"> | ||
<appender-ref ref="CONSOLE"/> | ||
</logger> | ||
</springProfile> | ||
|
||
<springProfile name="local"> | ||
<root level="DEBUG"> | ||
<appender-ref ref="CONSOLE"/> | ||
</root> | ||
</springProfile> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters