Skip to content

Commit

Permalink
Merge pull request #200 from kkkapuq/main
Browse files Browse the repository at this point in the history
stage to main merge
  • Loading branch information
kkkapuq authored Jan 29, 2024
2 parents 8a514a3 + ca32e3c commit d30bcc7
Show file tree
Hide file tree
Showing 198 changed files with 10,265 additions and 1,008 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/bepo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Orury CD with Gradle

env:
PROJECT_NAME: orury
BUCKET_NAME: orury-bepo-bucket
CODE_DEPLOY_APP_NAME: orury-code-deploy
DEPLOYMENT_GROUP_NAME: orury-code-deploy-group

on:
push:
branches: [ "main" ]

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

- run: touch ./orury-client/src/main/resources/application-secret.properties
- run: echo "${{ secrets.APPLICATION_SECRET }}" > ./orury-client/src/main/resources/application-secret.properties
- run: cat ./orury-client/src/main/resources/application-secret.properties

- name: Run chmod to make gradlew executable
run: chmod +x ./gradlew
shell: bash

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

- name: Make zip file
run: zip -r ./$GITHUB_SHA.zip .
shell: bash

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }} # 등록한 Github Secret이 자동으로 불려온다.
aws-secret-access-key: ${{ secrets.AWS_ACCESS_SECRET }} # 등록한 Github Secret이 자동으로 불려온다.
aws-region: ap-northeast-2

- name: Upload to S3
run: aws s3 cp --region ap-northeast-2 ./$GITHUB_SHA.zip s3://$BUCKET_NAME/$PROJECT_NAME/$GITHUB_SHA.zip

- name: Code Deploy
run: aws deploy create-deployment --application-name $CODE_DEPLOY_APP_NAME --deployment-config-name CodeDeployDefault.OneAtATime --deployment-group-name $DEPLOYMENT_GROUP_NAME --s3-location bucket=$BUCKET_NAME,bundleType=zip,key=$PROJECT_NAME/$GITHUB_SHA.zip
53 changes: 11 additions & 42 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
name: Java CI with Gradle

env:
PROJECT_NAME: orury
BUCKET_NAME: orury-bucket
CODE_DEPLOY_APP_NAME: orury-deploy
DEPLOYMENT_GROUP_NAME: orury-deploy-group

on:
push:
branches: [ "develop" ]
Expand All @@ -21,39 +15,14 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Run chmod to make gradlew executable
run: chmod +x ./gradlew

- name: Build with Gradle
uses: gradle/gradle-build-action@v2
with:
arguments: clean build

# Build JAR file instead of zipping the entire project
# - name: Build JAR
# run: ./gradlew build


# 나중을 위한 자동 CI/CD
# - name: Make Zip File
# run: zip -qq -r ./$GITHUB_SHA.zip .
#
# - name: Configure AWS credentials
# uses: aws-actions/configure-aws-credentials@v1
# with:
# aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }} # 등록한 Github Secret이 자동으로 불려온다.
# aws-secret-access-key: ${{ secrets.AWS_ACCESS_SECRET }} # 등록한 Github Secret이 자동으로 불려온다.
# aws-region: ap-northeast-2
#
# - name: Upload to S3
# run: aws s3 cp --region ap-northeast-2 ./$GITHUB_SHA.zip s3://$BUCKET_NAME/$PROJECT_NAME/$GITHUB_SHA.zip
#
# - name: Code Deploy
# run: aws deploy create-deployment --application-name $CODE_DEPLOY_APP_NAME --deployment-config-name CodeDeployDefault.OneAtATime --deployment-group-name $DEPLOYMENT_GROUP_NAME --s3-location bucket=$BUCKET_NAME,bundleType=zip,key=$PROJECT_NAME/$GITHUB_SHA.zip
#
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Run chmod to make gradlew executable
run: chmod +x ./gradlew

- name: Build with Test
run: ./gradlew clean build test
36 changes: 36 additions & 0 deletions appspec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
version: 0.0
os: linux
files:
- source: /
destination: /home/ec2-user/orury/
overwrite: yes

permissions:
- object: /
pattern: "**"
mode: '755'
owner: ec2-user
group: ec2-user

hooks:
BeforeInstall:
- location: scripts/deploy.sh
timeout: 60
runas: ec2-user
command: chmod +x /home/ec2-user/orury/scripts/deploy.sh

ApplicationStart:
- location: scripts/deploy.sh
timeout: 60
runas: ec2-user
#hooks:
# ApplicationStart:
# - location: scripts/run_new_was.sh
# timeout: 180
# runas: ec2-user
# - location: scripts/health_check.sh
# timeout: 180
# runas: ec2-user
# - location: scripts/switch.sh
# timeout: 180
# runas: ec2-user
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,13 @@ subprojects {
}

dependencies {
//web
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'

implementation 'io.netty:netty-resolver-dns-native-macos:4.1.68.Final:osx-aarch_64'
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package org.fastcampus.oruryadmin.global.security.jwt;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.web.access.AccessDeniedHandler;
import org.springframework.stereotype.Component;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package org.fastcampus.oruryadmin.global.security.jwt;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;
import org.springframework.stereotype.Component;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
Expand Down
4 changes: 2 additions & 2 deletions orury-admin/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ management.endpoints.web.exposure.include: "*"

logging:
level:
org.task-tracker.project: info

org.springframework.web.servlet: info
org.hibernate.type.descriptor.sql.BasicBinder: trace
springdoc:
Expand Down Expand Up @@ -60,7 +60,7 @@ spring:
jwt:
header: Authorization
#HS512 알고리즘을 사용할 것이기 때문에 512bit, 즉 64byte 이상의 secret key를 사용해야 한다.
# echo org-fastcampus-orury-core-api-admin-batch-org-fastcampus-orury-core-api-admin-batch | base64
# echo org-fastcampus-orury-core-api-admin-batch-org-fastcampus-orury-core-api-admin-batch | base64
secret: b3JnLWZhc3RjYW1wdXMtb3J1cnktY29yZS1hcGktYWRtaW4tYmF0Y2gtb3JnLWZhc3RjYW1wdXMtb3J1cnktY29yZS1hcGktYWRtaW4tYmF0Y2gK
token-validity-in-seconds: 86400
---
Expand Down
26 changes: 19 additions & 7 deletions orury-batch/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,33 @@ configurations {
extendsFrom annotationProcessor
}
}

dependencies {
implementation project(':orury-domain')
implementation project(':orury-common')
implementation project(':orury-domain')

//batch
implementation 'org.springframework.boot:spring-boot-starter-batch'
testImplementation 'org.springframework.batch:spring-batch-test'

//quartz
implementation 'org.springframework.boot:spring-boot-starter-quartz'

//jpa
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'

//lombok
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
//web client
implementation 'org.springframework.boot:spring-boot-starter-webflux'

//hsqldb
runtimeOnly 'org.hsqldb:hsqldb'

//mysql
runtimeOnly 'com.mysql:mysql-connector-j'
//
//flyway
implementation 'org.flywaydb:flyway-core'
implementation 'org.flywaydb:flyway-mysql'
}
tasks.register("prepareKotlinBuildScriptModel") {}

tasks.named('bootJar') {
enabled = true
Expand All @@ -46,4 +58,4 @@ tasks.named('jar') {

tasks.named('test') {
useJUnitPlatform()
}
}
1 change: 0 additions & 1 deletion orury-batch/settings.gradle

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration;
import org.springframework.scheduling.annotation.EnableScheduling;

@SpringBootApplication(scanBasePackages = {"org.fastcampus.orurycommon", "org.fastcampus.orurybatch"}, exclude = FlywayAutoConfiguration.class)
@EnableScheduling
@SpringBootApplication(scanBasePackages = {"org.fastcampus.orurybatch", "org.fastcampus.orurydomain", "org.fastcampus.orurycommon"}, exclude = FlywayAutoConfiguration.class)
public class OruryBatchApplication {

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

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package org.fastcampus.orurybatch.client;

import lombok.extern.slf4j.Slf4j;
import org.fastcampus.orurybatch.dto.KakaoMapGymResponse;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpHeaders;
import org.springframework.web.reactive.function.client.WebClient;

@Slf4j
@Configuration
public class KakaoMapClient {
@Value("${spring.kakao.key}")
private String env;

@Value("${spring.kakao.baseurl}")
private String BASE_URL;

@Bean
public WebClient.Builder webClientBuilder() {
return WebClient.builder();
}

@Bean
public WebClient webClient() {
return webClientBuilder()
.baseUrl(BASE_URL)
.defaultHeader(HttpHeaders.AUTHORIZATION, env)
.build();
}

public KakaoMapGymResponse searchGyms(String location, int page) {
String queryParam = "서울시" + location + "클라이밍";
log.info("queryParam: {}, page: {}", queryParam, page);
return webClient().get()
.uri(uriBuilder -> uriBuilder
.queryParam("query", queryParam)
.queryParam("page", page)
.build()
)
.retrieve()
.bodyToMono(KakaoMapGymResponse.class)
.block();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package org.fastcampus.orurybatch.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.batch.core.BatchStatus;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.JobExecutionListener;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class JobCompletionNotificationListener implements JobExecutionListener {

// private final JdbcTemplate jdbcTemplate;
//
// public JobCompletionNotificationListener(JdbcTemplate jdbcTemplate) {
// this.jdbcTemplate = jdbcTemplate;
// }

@Override
public void afterJob(JobExecution jobExecution) {
if (jobExecution.getStatus() == BatchStatus.COMPLETED) {
log.info("!!! JOB FINISHED! Time to verify the results");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.fastcampus.orurybatch.config;

import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;

@Configuration
@EntityScan(basePackages = "org.fastcampus.orurydomain")
@EnableJpaRepositories(basePackages = "org.fastcampus.orurydomain")
@EnableJpaAuditing
public class JpaAuditingConfig {

}
Loading

0 comments on commit d30bcc7

Please sign in to comment.