From cbc5092d7344d9094b4ea7fc070ceceddc077687 Mon Sep 17 00:00:00 2001 From: can019 Date: Sat, 27 Sep 2025 23:20:50 +0900 Subject: [PATCH 1/3] =?UTF-8?q?refactor:=20production=20=ED=99=98=EA=B2=BD?= =?UTF-8?q?=EC=97=90=EC=84=9C=20log,=20application=20yml=20mount=EB=A1=9C?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 외부 ec2에서 mount 되도록 설정 --- .github/workflows/deploy-java.yml | 32 +++++++++++++++++++++++++++- docker/production/docker-compose.yml | 3 +++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy-java.yml b/.github/workflows/deploy-java.yml index bb4483dd..4b4eecaf 100644 --- a/.github/workflows/deploy-java.yml +++ b/.github/workflows/deploy-java.yml @@ -79,7 +79,7 @@ jobs: source: "docker/production/promtail-config.yml" target: "~/app" - - name: Copy promtail-config to EC2 + - name: Copy agent-config to EC2 uses: appleboy/scp-action@v0.1.7 with: host: ${{ secrets.SERVER_HOST }} @@ -89,6 +89,36 @@ jobs: target: "~/app" overwrite: true + - name: Copy application.yml to EC2 + uses: appleboy/scp-action@v0.1.7 + with: + host: ${{ secrets.SERVER_HOST }} + username: ubuntu + key: ${{ secrets.SERVER_SSH_KEY }} + source: "apps/user-service/src/main/resources/application.yml" + target: "~/app/docker/production/config/application.yml" + overwrite: true + + - name: Copy application-production.yml to EC2 + uses: appleboy/scp-action@v0.1.7 + with: + host: ${{ secrets.SERVER_HOST }} + username: ubuntu + key: ${{ secrets.SERVER_SSH_KEY }} + source: "apps/user-service/src/main/resources/application-production.yml" + target: "~/app/docker/production/config/application-production.yml" + overwrite: true + + - name: Copy log4j2-production.yml to EC2 + uses: appleboy/scp-action@v0.1.7 + with: + host: ${{ secrets.SERVER_HOST }} + username: ubuntu + key: ${{ secrets.SERVER_SSH_KEY }} + source: "apps/user-service/src/main/resources/log4j2-production.yml" + target: "~/app/docker/production/config/log4j2-production.yml" + overwrite: true + - name: Deploy on EC2 uses: appleboy/ssh-action@v1.0.3 with: diff --git a/docker/production/docker-compose.yml b/docker/production/docker-compose.yml index 6d9a3c10..b6e6d983 100644 --- a/docker/production/docker-compose.yml +++ b/docker/production/docker-compose.yml @@ -32,6 +32,9 @@ services: - SPRING_PROFILES_ACTIVE=production volumes: - logs_volume:/logs + - ./config/application.yml:/app/src/main/resources/application.yml:ro + - ./config/application-production.yml:/app/src/main/resources/application-production.yml:ro + - ./config/log4j2-production.yml:/app/src/main/resources/log4j2-production.yml:ro # Grafana Agent만으로 메트릭 수집 + 전송 grafana-agent: From c98a10c4f841a91da9e2a6c4efa51830eb5df8c2 Mon Sep 17 00:00:00 2001 From: can019 Date: Sat, 27 Sep 2025 23:29:01 +0900 Subject: [PATCH 2/3] =?UTF-8?q?refactor:=20Production=20jar=EC=97=90=20?= =?UTF-8?q?=ED=95=84=EC=9A=94=ED=95=9C=20resource=EB=A7=8C=20export?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy-java.yml | 10 ---------- apps/user-service/build.gradle | 7 +++++++ docker/production/docker-compose.yml | 4 +--- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/.github/workflows/deploy-java.yml b/.github/workflows/deploy-java.yml index 4b4eecaf..facbdd1c 100644 --- a/.github/workflows/deploy-java.yml +++ b/.github/workflows/deploy-java.yml @@ -89,16 +89,6 @@ jobs: target: "~/app" overwrite: true - - name: Copy application.yml to EC2 - uses: appleboy/scp-action@v0.1.7 - with: - host: ${{ secrets.SERVER_HOST }} - username: ubuntu - key: ${{ secrets.SERVER_SSH_KEY }} - source: "apps/user-service/src/main/resources/application.yml" - target: "~/app/docker/production/config/application.yml" - overwrite: true - - name: Copy application-production.yml to EC2 uses: appleboy/scp-action@v0.1.7 with: diff --git a/apps/user-service/build.gradle b/apps/user-service/build.gradle index 16905e8e..3660ab02 100644 --- a/apps/user-service/build.gradle +++ b/apps/user-service/build.gradle @@ -160,6 +160,13 @@ bootJar { from ("${asciidoctor.outputDir}/html5") { into 'static/docs' } + + // 프로덕션 JAR에서 불필요한 파일들 제외 + exclude 'application-test-*.yml' + exclude 'log4j2-test-*.yml' + exclude 'application-develop.yml' + exclude 'log4j2-develop.yml' + exclude 'sql/**' } spotless { diff --git a/docker/production/docker-compose.yml b/docker/production/docker-compose.yml index b6e6d983..35ecb706 100644 --- a/docker/production/docker-compose.yml +++ b/docker/production/docker-compose.yml @@ -32,9 +32,7 @@ services: - SPRING_PROFILES_ACTIVE=production volumes: - logs_volume:/logs - - ./config/application.yml:/app/src/main/resources/application.yml:ro - - ./config/application-production.yml:/app/src/main/resources/application-production.yml:ro - - ./config/log4j2-production.yml:/app/src/main/resources/log4j2-production.yml:ro + - ./config:/app/config:ro # Grafana Agent만으로 메트릭 수집 + 전송 grafana-agent: From 343dc0eb3e269e3d36e0b1dd7703448aca614bab Mon Sep 17 00:00:00 2001 From: can019 Date: Sat, 27 Sep 2025 23:31:20 +0900 Subject: [PATCH 3/3] =?UTF-8?q?feat:=20Production=20=ED=99=98=EA=B2=BD?= =?UTF-8?q?=EC=97=90=EC=84=9C=2030=EC=B4=88=EB=A7=88=EB=8B=A4=20log=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95=20load?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/user-service/src/main/resources/log4j2-production.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/user-service/src/main/resources/log4j2-production.yml b/apps/user-service/src/main/resources/log4j2-production.yml index ae8e9aba..79d920fc 100644 --- a/apps/user-service/src/main/resources/log4j2-production.yml +++ b/apps/user-service/src/main/resources/log4j2-production.yml @@ -1,6 +1,7 @@ Configuration: status: INFO name: production + monitorInterval: 30 properties: property: