Log 생성하는 Application 개발 및 Image Build 및 Push

https://github.com/seojeonghyeon/filebeatdemo

FROM openjdk:17-ea-11-slim
COPY target/filebeatdemo-0.0.1.jar filebeatdemo.jar
ENTRYPOINT ["java","-jar","filebeatdemo.jar"]

1. Package 파일(JAR) 생성

zayden@Zaydenui-MacBookPro  ~/Documents/workspace/filebeatdemo  mvn clean compile package -DskipTests=true
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------< com.example:filebeatdemo >----------------------
[INFO] Building filebeatdemo 0.0.1
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:3.2.0:clean (default-clean) @ filebeatdemo ---
[INFO] Deleting /Users/zayden/Documents/workspace/filebeatdemo/target
[INFO]
[INFO] --- maven-resources-plugin:3.3.1:resources (default-resources) @ filebeatdemo ---
[INFO] Copying 1 resource from src/main/resources to target/classes
[INFO] Copying 1 resource from src/main/resources to target/classes
[INFO]
[INFO] --- maven-compiler-plugin:3.10.1:compile (default-compile) @ filebeatdemo ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 6 source files to /Users/zayden/Documents/workspace/filebeatdemo/target/classes
[INFO]
[INFO] --- maven-resources-plugin:3.3.1:resources (default-resources) @ filebeatdemo ---
[INFO] Copying 1 resource from src/main/resources to target/classes
[INFO] Copying 1 resource from src/main/resources to target/classes
[INFO]
[INFO] --- maven-compiler-plugin:3.10.1:compile (default-compile) @ filebeatdemo ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 6 source files to /Users/zayden/Documents/workspace/filebeatdemo/target/classes
[INFO]
[INFO] --- maven-resources-plugin:3.3.1:testResources (default-testResources) @ filebeatdemo ---
[INFO] skip non existing resourceDirectory /Users/zayden/Documents/workspace/filebeatdemo/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.10.1:testCompile (default-testCompile) @ filebeatdemo ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /Users/zayden/Documents/workspace/filebeatdemo/target/test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.22.2:test (default-test) @ filebeatdemo ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-jar-plugin:3.3.0:jar (default-jar) @ filebeatdemo ---
[INFO] Building jar: /Users/zayden/Documents/workspace/filebeatdemo/target/filebeatdemo-0.0.1.jar
[INFO]
[INFO] --- spring-boot-maven-plugin:3.0.6:repackage (repackage) @ filebeatdemo ---
[INFO] Replacing main artifact with repackaged archive
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  4.220 s
[INFO] Finished at: 2023-05-20T11:55:22+09:00
[INFO] ------------------------------------------------------------------------

2. Docker Image File Build

 zayden@Zaydenui-MacBookPro  ~/Documents/workspace/filebeatdemo  docker build --tag seojeonghyeon0630/filebeatdemo:0.0.1 .
[+] Building 3.6s (8/8) FINISHED
 => [internal] load build definition from Dockerfile      0.1s
 => => transferring dockerfile: 180B                      0.0s
 => [internal] load .dockerignore                         0.1s
 => => transferring context: 2B                           0.0s
 => [internal] load metadata for docker.io/library/openj  2.7s
 => [auth] library/openjdk:pull token for registry-1.doc  0.0s
 => [internal] load build context                         0.3s
 => => transferring context: 18.71MB                      0.3s
 => [1/2] FROM docker.io/library/openjdk:17-ea-11-slim@s  0.0s
 => [2/2] COPY target/filebeatdemo-0.0.1.jar filebeatdem  0.3s
 => exporting to image                                    0.1s
 => => exporting layers                                   0.1s
 => => writing image sha256:42bfd6721846a31a040b47546c85  0.0s
 => => naming to docker.io/seojeonghyeon0630/filebeatdem  0.0s

Use 'docker scan' to run Snyk tests against images to find vulnerabilities and learn how to fix them

3. Docker Image File Push

 zayden@Zaydenui-MacBookPro  ~/Documents/workspace/filebeatdemo  docker push seojeonghyeon0630/filebeatdemo:0.1.1
The push refers to repository [docker.io/seojeonghyeon0630/filebeatdemo]
0dbf810561fe: Pushed
3d3fdb9815af: Mounted from seojeonghyeon0630/matching-service
08664b16f94c: Mounted from seojeonghyeon0630/matching-service
9eb82f04c782: Mounted from seojeonghyeon0630/matching-service

*Version 0.1.1 이후 Standard Verion

* 이 글은 글쓴이의 Notion에서 옮긴 글입니다.

 

선수 지식 : Kafka, Kubernetes, ELK

 

전체 구성도

1) 운영환경

 

2) 개발 환경

 

Namespace

 

 

국가 기관이나 기업체에서는 외부사이트가 함부로 접근하지 못하도록 내부망이 구성되어 있는데, 내부망 내 PC에서 연구 프로그램을 돌릴 경우 로그를 확인하기 위해 매번 출근해서 확인해야한다고 한다. 그래서 제목과 같은 프로그램을 개발하게 되었고 현재 1차 개발이 마무리가 되어 이를 포스팅하게 되었다. 주니어 개발자인데다 2-3일 안에 만든 프로그램이라 그리 썩 잘만들진 않았지만, 애들 공놀이 하는 것 바라보는 양 이쁘게 봐주시길 바란다.

 

 

프로그램은 

1차 개발에서 하나의 폴더 내 로그파일들에 대해 이메일로 전송할 수 있게 끔 개발되었다.

2차 개발에서는 여러개의 폴더 내 로그파일들에 대해 이메일로 전송할 수 있게 끔 개발될 예정이다.

 

프로그램 구성

그림1. 프로그램 Package 구성

Package는 크게 controller, dto, listener, resource, service, view로 나누었다.

MVC모델을 적용하였고 변경이 일어날 수 있는 부분(이벤트, view등)들에 대해 싱글톤과 상속을 통해 의존성을 낮추었다.

(2차 개발이 시작되면 해당 부분만 변경해서 바꿔서 연결해주면 될테니까..)

listener는 이벤트 처리를 담당한다.

resource는 로고 파일과 개발단계에서 이전 데이터 저장을 했었다.

service는 파일의 입출력 처리와 스케줄러 기능(시간마다 정해진 기능 수행), 이메일 전송 등등 포함되어 있다.

 

그림2. Controller Package 구성

MainController는 프로그램 시작 시, view와 연결해주는 부분이다. 딱히 그 외에 용도로는 안쓰인다.

FileController는 파일 입, 출력 Service와 연결해주는 부분이다.

 

그림3. view Package 구성

MainFrame은 프레임을 구성하는 부분이다. 이 부분에 대해서 크게 변동이 없을 것으로 예상되서 하나만 만들어 주었다.

panel은 Frame 내 panel을 구성하는 부분이다. 현재 basicpanel을 구성하였고 2차 개발에 들어가게 되면 변동이 생기게 될 부분이다.

dialog는 서브 창을 의미하는데, 현재 파일 찾기 창이 이 안에 구성되어 있다.

 

 

소스코드는 Github에 올려두었으니, 참고하면 된다.

https://github.com/seojeonghyeon/SendLogFilesByEmail

+ Recent posts