-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feature/#17-add-efk-log
- Loading branch information
Showing
11 changed files
with
217 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: backend - CI | ||
on: | ||
push: | ||
branches: | ||
- develop | ||
env: | ||
AWS_REGION: ap-northeast-2 | ||
ECR_REPOSITORY: kakaoasset-backend | ||
jobs: | ||
build-and-push-image: | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v1 | ||
with: | ||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
aws-region: ${{ env.AWS_REGION }} | ||
|
||
- name: Login to Amazon ECR | ||
id: login-ecr | ||
uses: aws-actions/amazon-ecr-login@v1 | ||
|
||
- name: Docker Build and ECR push | ||
id: docker_build | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
file: Dockerfile | ||
push: true | ||
tags: ${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_REPOSITORY }}:${{ github.sha }} | ||
|
||
- name: Move Repository | ||
uses: actions/checkout@master | ||
with: | ||
repository: kakao-asset/k8s | ||
token: ${{ secrets.TOKEN }} | ||
path: . | ||
|
||
- name: Edit Back Deploy menifest | ||
run: | | ||
sed -i "20 c\ image: ${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_REPOSITORY }}:${{ github.sha }}" back-deploy.yaml | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "ur2e" | ||
git add . | ||
git commit -m "update back-deploy.yaml" | ||
git push -f --set-upstream origin main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
FROM gradle:7.4-jdk17-alpine as builder | ||
WORKDIR /build | ||
COPY . /build/ | ||
RUN chmod 777 gradlew | ||
RUN ./gradlew bootJar | ||
WORKDIR /build/build/libs | ||
|
||
FROM eclipse-temurin:11-jre-alpine | ||
COPY --from=builder /build/build/libs/kakaoasset-0.0.1-SNAPSHOT.jar kakaoasset-0.0.1-SNAPSHOT.jar | ||
EXPOSE 8080 | ||
ENTRYPOINT ["java", "-jar", "kakaoasset-0.0.1-SNAPSHOT.jar"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
src/main/java/com/kakaoasset/portfolio/service/SearchRankService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package com.kakaoasset.portfolio.service; | ||
|
||
|
||
import org.json.JSONArray; | ||
import org.json.JSONObject; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.http.HttpEntity; | ||
import org.springframework.http.HttpHeaders; | ||
import org.springframework.http.HttpMethod; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.http.client.ClientHttpResponse; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.web.client.HttpClientErrorException; | ||
import org.springframework.web.client.RestTemplate; | ||
|
||
/** | ||
*packageName : com.kakaoasset.portfolio.elasticsearch.elasticAPI.service | ||
* fileName : SearchRankController | ||
* author : Hwang | ||
* date : 2022-11-14 | ||
*/ | ||
|
||
@Service | ||
public class SearchRankService { | ||
|
||
@Value("${elasticsearch.host}") | ||
private String host; | ||
|
||
@Value("${index.stock-rank-index}") | ||
private String rankIndex; | ||
|
||
|
||
public String selectSearchRank(){ | ||
JSONArray jsonarr = new JSONArray(); | ||
String result = null; | ||
|
||
// make request for elasticsearch api | ||
RestTemplate restTemplate = new RestTemplate(); | ||
restTemplate.getInterceptors().add((request, body, execution) -> { | ||
ClientHttpResponse response = execution.execute(request,body); | ||
response.getHeaders().setContentType(MediaType.APPLICATION_JSON); | ||
return response; | ||
}); | ||
final HttpHeaders headers = new HttpHeaders(); | ||
final HttpEntity<?> entity = new HttpEntity<>(headers); | ||
try { | ||
// send request to elasticsearch | ||
|
||
result = restTemplate.exchange("http://"+host+":9200/"+rankIndex+"/_search?sort=datetime:acs", HttpMethod.GET, entity, String.class).getBody(); | ||
}catch (HttpClientErrorException e){ | ||
// no index | ||
return new JSONObject("{\"error\":\"No Index\"").toString(); | ||
} | ||
|
||
JSONObject json = new JSONObject(result); | ||
for (int i = 0; i < json.getJSONObject("hits").getJSONArray("hits").length(); i++) { | ||
JSONObject temp = ((JSONObject) json.getJSONObject("hits").getJSONArray("hits").get(i)).getJSONObject("_source"); | ||
jsonarr.put(temp); | ||
} | ||
return jsonarr.toString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.