Skip to content

Commit

Permalink
Merge pull request #196 from SMWU-POCHAK/feat/#180-new-relic
Browse files Browse the repository at this point in the history
[Feat/#180-new-relic] new relic 설정
  • Loading branch information
dudrhy12 authored Feb 24, 2025
2 parents 0459f49 + 8d14523 commit 7e69a2b
Show file tree
Hide file tree
Showing 5 changed files with 450 additions and 4 deletions.
12 changes: 11 additions & 1 deletion .github/workflows/dev-server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: dev server

env:
JASYPT_KEY: ${{ secrets.JASYPT_KEY }}
NEW_RELIC_LICENSE_KEY: ${{ secrets.NEW_RELIC_LICENSE_KEY }}

on:
push:
Expand Down Expand Up @@ -44,6 +45,13 @@ jobs:
run: chmod +x ./gradlew
shell: bash

- name: Download and Extract New Relic
run: |
mkdir -p newrelic
curl -o newrelic/newrelic-java.zip https://download.newrelic.com/newrelic/java-agent/newrelic-agent/current/newrelic-java.zip
unzip newrelic/newrelic-java.zip -d newrelic/
shell: bash

- name: Build with Gradle
run: ./gradlew clean build
shell: bash
Expand All @@ -64,6 +72,8 @@ jobs:
build-args: |
SPRING_PROFILES_ACTIVE=DEV
JASYPT_KEY=${{ secrets.JASYPT_KEY }}
NEW_RELIC_LICENSE_KEY=${{ secrets.NEW_RELIC_LICENSE_KEY }}
- name: Execute remote ssh & Deploy Dev server
uses: appleboy/ssh-action@master
Expand All @@ -72,4 +82,4 @@ jobs:
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_KEY }}
port: ${{ secrets.SSH_PORT }}
script: sudo sh deploy.sh
script: sudo sh deploy.sh
2 changes: 1 addition & 1 deletion .github/workflows/prod-server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@ jobs:
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_KEY }}
port: ${{ secrets.SSH_PORT }}
script: sudo sh deploy.sh
script: sudo sh deploy.sh
6 changes: 5 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
FROM openjdk:17-jdk
WORKDIR /app
COPY build/libs/*.jar app.jar
COPY newrelic/ /app/newrelic/
EXPOSE 5000

ARG SPRING_PROFILES_ACTIVE
ARG JASYPT_KEY
ARG NEW_RELIC_LICENSE_KEY

ENV SPRING_PROFILES_ACTIVE=${SPRING_PROFILES_ACTIVE:-DEV}
ENV JASYPT_KEY=${JASYPT_KEY:-pw}
ENV NEW_RELIC_LICENSE_KEY=${NEW_RELIC_LICENSE_KEY}

CMD java -jar -Duser.timezone=Asia/Seoul app.jar

CMD java -javaagent:/app/newrelic/newrelic.jar -Duser.timezone=Asia/Seoul -jar app.jar
34 changes: 33 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ plugins {
id 'org.asciidoctor.jvm.convert' version '3.3.2'
id 'jacoco'
id "org.sonarqube" version "4.4.1.3373"
id "de.undercouch.download" version "5.3.0"
}

group = 'com.apps'
Expand All @@ -25,6 +26,22 @@ repositories {
mavenCentral()
}

task downloadNewrelic(type: Download) {
mkdir 'newrelic'
src 'https://download.newrelic.com/newrelic/java-agent/newrelic-agent/current/newrelic-java.zip'
dest file('newrelic/newrelic-java.zip')

onlyIf { !file('newrelic/newrelic-java.zip').exists() }
}

task unzipNewrelic(type: Copy) {
dependsOn downloadNewrelic
from zipTree(file('newrelic/newrelic-java.zip'))
into rootDir
}

build.dependsOn unzipNewrelic

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-validation'
Expand Down Expand Up @@ -126,7 +143,6 @@ bootJar {
dependsOn copyDocument
}

// -plain.jar 제거
jar {
enabled = false
}
Expand Down Expand Up @@ -194,3 +210,19 @@ sonarqube {
property "sonar.coverage.exclusions", "**/entity/**, **/dto/**, **/config/**, **/global/image/**, **/domain/**, **/annotation/**"
}
}

tasks.named('compileJava') {
dependsOn unzipNewrelic
}
tasks.named('processResources') {
dependsOn unzipNewrelic
}
tasks.named('processTestResources') {
dependsOn unzipNewrelic
}
tasks.named('compileTestJava') {
dependsOn unzipNewrelic
}
tasks.named('test') {
dependsOn unzipNewrelic
}
Loading

0 comments on commit 7e69a2b

Please sign in to comment.