Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/156 ci/cd 트러블슈팅 #174

Merged
merged 8 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/dev_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ jobs:
run: chmod +x ./gradlew
shell: bash # (6).권한 부여

# clean build -x test
- name: Build with Gradle
run: ./gradlew clean build -x test
run: ./gradlew Briefing-Api:bootJar
shell: bash # (7).build 시작

- name: Get current time
Expand All @@ -45,7 +46,7 @@ jobs:
- name: Generate deployment package
run: |
mkdir -p deploy
cp build/libs/*.jar deploy/application.jar
cp Briefing-Api/build/libs/*.jar deploy/Briefing-Api-application.jar
cp Procfile deploy/Procfile
cp -r .ebextensions-dev deploy/.ebextensions
cp -r .platform deploy/.platform
Expand Down
60 changes: 60 additions & 0 deletions Briefing-Api/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@

tasks.named('bootJar') { //빌드할 때 bootjar 파일로 하겠다는 의미
enabled = true
}

tasks.named('jar') { //빌드할 때 jar 파일로 하겠다는 의미
enabled = false
}

dependencies {

implementation project(':core:Briefing-Common')
implementation project(':core:Briefing-Infra')
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
// querydsl
// == 스프링 부트 3.0 이상 ==
implementation 'com.querydsl:querydsl-jpa:5.0.0:jakarta'
annotationProcessor "com.querydsl:querydsl-apt:${dependencyManagement.importedProperties['querydsl.version']}:jakarta"
annotationProcessor "jakarta.annotation:jakarta.annotation-api"
annotationProcessor "jakarta.persistence:jakarta.persistence-api"

implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-data-redis:2.3.1.RELEASE'
implementation 'org.springframework.boot:spring-boot-starter-security'

implementation 'io.springfox:springfox-swagger2:2.9.2'
implementation 'io.springfox:springfox-swagger-ui:2.9.2'
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.0.2'
implementation 'org.springframework.cloud:spring-cloud-starter-openfeign'
implementation 'com.googlecode.json-simple:json-simple:1.1.1'
implementation 'mysql:mysql-connector-java' // 추가 작성

implementation platform("org.springframework.cloud:spring-cloud-dependencies:2022.0.3")
compileOnly 'org.projectlombok:lombok'
runtimeOnly 'com.h2database:h2'
// runtimeOnly 'org.postgresql:postgresql'
// runtimeOnly 'com.mysql:mysql-connector-j'

// jwt 의존성
runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.11.5'
runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.11.5'
implementation 'io.jsonwebtoken:jjwt-api:0.11.5'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'

// fcm 의존성
implementation 'com.google.firebase:firebase-admin:9.1.1'

//spring batch 의존성
implementation 'org.springframework.boot:spring-boot-starter-batch'
}

tasks.named('test') {
useJUnitPlatform()
}

tasks.named('test') {
useJUnitPlatform()
}
Binary file added Briefing-Api/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
7 changes: 7 additions & 0 deletions Briefing-Api/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.example.briefingapi;

import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.servers.Server;
import lombok.RequiredArgsConstructor;
import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.cloud.openfeign.FeignAutoConfiguration;
import org.springframework.data.redis.repository.configuration.EnableRedisRepositories;


@OpenAPIDefinition(
servers = {
@Server(url = "http://localhost:8080", description = "local server"),
@Server(url = "https://dev.briefing.store", description = "dev server"),
@Server(url = "https://api.newsbreifing.store", description = "release server")
})
@SpringBootApplication(scanBasePackages = {"com.example.briefingapi","com.example.briefingcommon","com.example.briefinginfra"})
@RequiredArgsConstructor
@EnableCaching
@EnableFeignClients(basePackages = "com.example.briefinginfra")
@EnableRedisRepositories
@ImportAutoConfiguration({FeignAutoConfiguration.class})
public class BriefingApiApplication {

public static void main(String[] args) {
SpringApplication.run(BriefingApiApplication.class, args);
}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package briefing.common.aop.annotation;
package com.example.briefingapi.aop.annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package briefing.common.aop.aspect;
package com.example.briefingapi.aop.aspect;

import java.util.Optional;

import com.example.briefingapi.aop.annotation.CacheEvictByBriefingId;
import com.example.briefingcommon.domain.repository.article.BriefingRepository;
import com.example.briefingcommon.entity.Briefing;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
Expand All @@ -13,9 +16,7 @@
import org.springframework.expression.spel.support.StandardEvaluationContext;
import org.springframework.stereotype.Component;

import briefing.briefing.domain.Briefing;
import briefing.briefing.domain.repository.BriefingRepository;
import briefing.common.aop.annotation.CacheEvictByBriefingId;

import lombok.RequiredArgsConstructor;

@Aspect
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.example.briefingapi.batch.job;

import com.example.briefingapi.fcm.implementation.FcmCommandService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.Step;
import org.springframework.batch.core.job.builder.JobBuilder;
import org.springframework.batch.core.repository.JobRepository;
import org.springframework.batch.core.step.builder.StepBuilder;
import org.springframework.batch.core.step.tasklet.Tasklet;
import org.springframework.batch.repeat.RepeatStatus;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.PlatformTransactionManager;

@Slf4j
@Configuration
@RequiredArgsConstructor
public class DailyPushJobConfig {

private final FcmCommandService fcmCommandService;

@Value("${fcm.topic.daily-push}")
private String dailyPushTopic;

@Bean
public Job dailyPushJob(JobRepository jobRepository, Step simpleStep1) {
return new JobBuilder("daily Push", jobRepository)
.start(simpleStep1)
.build();
}

@Bean
public Step dailyPushStep(JobRepository jobRepository, Tasklet testTasklet, PlatformTransactionManager platformTransactionManager){
return new StepBuilder("dailyPushStep", jobRepository)
.tasklet(testTasklet, platformTransactionManager).build();
}
@Bean
public Tasklet dailyPushTasklet(){
return ((contribution, chunkContext) -> {
log.info("request FCM!!");
fcmCommandService.sendMessage(dailyPushTopic);
return RepeatStatus.FINISHED;
});
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.example.briefingapi.batch.scheduler;

import com.example.briefingapi.fcm.implementation.FcmCommandService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobExecutionException;
import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.JobParametersBuilder;
import org.springframework.batch.core.launch.JobLauncher;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Slf4j
@Component
@RequiredArgsConstructor
@EnableScheduling
public class DailyPush {

private final JobLauncher jobLauncher;

private final Job job;

// 초 분 시 일 월 요일
@Scheduled(cron = "0 0 8,17 * * *")
public void requestDailyTopicFcmJob(){
log.info("daily alarm launched");
try {
JobParameters jobParameters = new JobParametersBuilder()
.addLong("executedTime", System.currentTimeMillis())
.toJobParameters();

jobLauncher.run(job, jobParameters);
} catch (JobExecutionException e) {
log.error("SeatReleaseScheduler error : ", e);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package briefing.briefing.business;
package com.example.briefingapi.briefing.business;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

import briefing.briefing.domain.Article;
import briefing.briefing.domain.Briefing;
import briefing.briefing.presentation.dto.BriefingRequestDTO;
import briefing.briefing.presentation.dto.BriefingResponseDTO;
import briefing.common.enums.BriefingType;
import com.example.briefingapi.briefing.presentation.dto.BriefingRequestDTO;
import com.example.briefingapi.briefing.presentation.dto.BriefingResponseDTO;
import com.example.briefingcommon.entity.Article;
import com.example.briefingcommon.entity.Briefing;
import com.example.briefingcommon.entity.enums.BriefingType;

public class BriefingConverter {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
package briefing.briefing.business;
package com.example.briefingapi.briefing.business;

import java.util.List;
import java.util.Optional;

import com.example.briefingapi.briefing.implement.service.ArticleCommandService;
import com.example.briefingapi.briefing.implement.service.BriefingArticleCommandService;
import com.example.briefingapi.briefing.implement.service.BriefingCommandService;
import com.example.briefingapi.briefing.implement.service.BriefingQueryService;
import com.example.briefingapi.briefing.presentation.dto.BriefingRequestDTO;
import com.example.briefingapi.briefing.presentation.dto.BriefingRequestParam;
import com.example.briefingapi.briefing.presentation.dto.BriefingResponseDTO;
import com.example.briefingapi.scrap.implement.ScrapQueryService;
import com.example.briefingcommon.entity.Article;
import com.example.briefingcommon.entity.Briefing;
import com.example.briefingcommon.entity.BriefingArticle;
import com.example.briefingcommon.entity.Member;
import com.example.briefingcommon.entity.enums.APIVersion;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import briefing.briefing.domain.Article;
import briefing.briefing.domain.Briefing;
import briefing.briefing.domain.BriefingArticle;
import briefing.briefing.implement.service.ArticleCommandService;
import briefing.briefing.implement.service.BriefingArticleCommandService;
import briefing.briefing.implement.service.BriefingCommandService;
import briefing.briefing.implement.service.BriefingQueryService;
import briefing.briefing.presentation.dto.BriefingRequestDTO;
import briefing.briefing.presentation.dto.BriefingRequestParam;
import briefing.briefing.presentation.dto.BriefingResponseDTO;
import briefing.common.enums.APIVersion;
import briefing.member.domain.Member;
import briefing.scrap.implement.ScrapQueryService;

import lombok.RequiredArgsConstructor;

@Component
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package briefing.briefing.business;
package com.example.briefingapi.briefing.business;

import java.util.List;
import java.util.Optional;

import com.example.briefingapi.briefing.implement.service.BriefingQueryService;
import com.example.briefingapi.briefing.presentation.dto.BriefingRequestParam;
import com.example.briefingapi.briefing.presentation.dto.BriefingResponseDTO;
import com.example.briefingapi.scrap.implement.ScrapQueryService;
import com.example.briefingcommon.entity.Briefing;
import com.example.briefingcommon.entity.Member;
import com.example.briefingcommon.entity.enums.APIVersion;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import briefing.briefing.domain.Briefing;
import briefing.briefing.implement.service.BriefingQueryService;
import briefing.briefing.presentation.dto.BriefingRequestParam;
import briefing.briefing.presentation.dto.BriefingResponseDTO;
import briefing.common.enums.APIVersion;
import briefing.member.domain.Member;
import briefing.scrap.implement.ScrapQueryService;
import lombok.RequiredArgsConstructor;

@Component
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package briefing.briefing.implement.context;
package com.example.briefingapi.briefing.implement.context;

import java.util.List;
import java.util.Optional;

import briefing.briefing.domain.Briefing;
import briefing.briefing.implement.strategy.BriefingQueryStrategy;
import briefing.briefing.presentation.dto.BriefingRequestParam;


import com.example.briefingapi.briefing.implement.strategy.BriefingQueryStrategy;
import com.example.briefingapi.briefing.presentation.dto.BriefingRequestParam;
import com.example.briefingcommon.entity.Briefing;
import lombok.RequiredArgsConstructor;

@RequiredArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package briefing.briefing.implement.context;
package com.example.briefingapi.briefing.implement.context;

import java.util.EnumMap;
import java.util.List;
import java.util.Map;

import com.example.briefingapi.briefing.implement.strategy.BriefingQueryStrategy;
import com.example.briefingcommon.entity.enums.APIVersion;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import briefing.briefing.implement.strategy.BriefingQueryStrategy;
import briefing.common.enums.APIVersion;

@Component
public class BriefingQueryContextFactory {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package briefing.briefing.implement.service;
package com.example.briefingapi.briefing.implement.service;

import java.util.List;

import com.example.briefingcommon.domain.repository.article.ArticleRepository;
import com.example.briefingcommon.entity.Article;
import org.springframework.stereotype.Service;

import briefing.briefing.domain.Article;
import briefing.briefing.domain.repository.ArticleRepository;

import lombok.RequiredArgsConstructor;

@Service
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package briefing.briefing.implement.service;
package com.example.briefingapi.briefing.implement.service;

import java.util.List;

import com.example.briefingcommon.domain.repository.article.BriefingArticleRepository;
import com.example.briefingcommon.entity.BriefingArticle;
import org.springframework.stereotype.Service;

import briefing.briefing.domain.BriefingArticle;
import briefing.briefing.domain.repository.BriefingArticleRepository;

import lombok.RequiredArgsConstructor;

@Service
Expand Down
Loading
Loading