Skip to content

Commit

Permalink
setUp: CI yml file setting
Browse files Browse the repository at this point in the history
  • Loading branch information
donghyuun committed Sep 6, 2024
1 parent 3ab2860 commit 9355d77
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 35 deletions.
55 changes: 22 additions & 33 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,30 @@
name: Build and Push Docker Imamge
name: Java CI with Gradle

on:
workflow_dispatch: # 수동 실행 트리거
# push:
# branches:
# - main
workflow_dispatch:
push:
branches:
- 'main'

jobs:
build-and-push:
name: Build and Push Docker Image
ci-pipeline:
runs-on: ubuntu-latest

steps: # 레포지토리 체크아웃
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up JDK 17 # JDK 17 설정
uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: '17'
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Build with Gradle # Gradle 빌드
run: ./gradlew build -x test
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: '17'

- name: Set up Docker Buildx # Docker Buildx 설정
uses: docker/setup-buildx-aciton@v2

- name: Login to Docker Hub # Docker Hub 로그인
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and Push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ secrets.DOCKER_USERNAME }}/spring-app:version1
- name: Grant execute permission for Gradle Wrapper
run: chmod +x ./gradlew

- name: Build with Gradle
run: ./gradlew build

- name: Test with Gradle
run: ./gradlew test
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# 도커 이미지를 빌드할 때 필요한 커맨드를 가짐

# jdk17 image start
FROM openjdk:17

# 인자 설정 - JAR_File
ARG JAR_FILE=build/libs/*.jar

# jar 파일 복제
COPY ${JAR_FILE} app.jar

# 실행 명령어
ENTRYPOINT ["java", "-jar", "app.jar"]

Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ public class InfoSpecifications {

public static Specification<Info> hasStartDate(LocalDate startDate) {
return (Root<Info> root, CriteriaQuery<?> query, CriteriaBuilder cb) ->
startDate == null ? cb.conjunction() : cb.greaterThanOrEqualTo(root.get("startDate"), startDate.atStartOfDay());
startDate == null ? cb.conjunction() : cb.greaterThanOrEqualTo(root.get("localDateTime"), startDate.atStartOfDay());
}

public static Specification<Info> hasEndDate(LocalDate endDate) {
return (Root<Info> root, CriteriaQuery<?> query, CriteriaBuilder cb) ->
endDate == null ? cb.conjunction() : cb.lessThanOrEqualTo(root.get("endDate"), endDate.atTime(23, 59, 59, 999_999_999));
endDate == null ? cb.conjunction() : cb.lessThanOrEqualTo(root.get("localDateTime"), endDate.atTime(23, 59, 59, 999_999_999));
}

public static Specification<Info> hasCameraName(String cameraName) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.example.apapbackend.domain.report;

import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/report")
@RequiredArgsConstructor
public class ReportController {

private final ReportService reportService;
private final ResourceLoader resourceLoader;

@Value("classpath:static/report.pdf")
private Resource resource;

@GetMapping
public ResponseEntity<Resource> getDailyReport() {
// 리소스 로더를 사용하여 리소스를 로드합니다.
org.springframework.core.io.Resource resource = resourceLoader.getResource(
"classpath:static/report.pdf");

try {
// 파일 다운로드를 위해 적절한 헤더를 설정합니다.
return ResponseEntity.ok()
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"2024_08_30_daily_report.pdf\"")
.body(this.resource);
} catch (Exception e) {
// 오류 처리
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
}
}
@Operation(summary = "주간 보고서 다운로드")
public void getWeeklyOfDay(

) {

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.example.apapbackend.domain.report;

import com.example.apapbackend.domain.Info.Info;
import com.example.apapbackend.domain.Info.InfoRepository;
import com.example.apapbackend.domain.Info.InfoService;
import java.time.LocalDate;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
public class ReportService {

private final InfoService infoService;

public void getDailyReport(LocalDate localDate) {
List<Info> infos = infoService.getInfos(localDate, localDate, null, null);
}
}
Binary file added src/main/resources/img_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/resources/static/report.pdf
Binary file not shown.

0 comments on commit 9355d77

Please sign in to comment.