Skip to content

Commit

Permalink
Merge pull request #32 from Jeju-Dorang/feat/배포-설정/#30
Browse files Browse the repository at this point in the history
[feat] 배포 설정
  • Loading branch information
choiseoji authored Sep 13, 2024
2 parents 3cecca5 + 3ce2bab commit 69af0f2
Show file tree
Hide file tree
Showing 6 changed files with 138 additions and 56 deletions.
7 changes: 7 additions & 0 deletions JejuDorang/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM openjdk:17
ARG JAR_FILE=build/libs/*.jar
ARG PROFILES
ARG ENV
COPY ${JAR_FILE} app.jar
COPY .env ./
ENTRYPOINT ["java", "-Dspring.profiles.active=${PROFILES}", "-Dserver.env=${ENV}", "-jar", "app.jar"]
46 changes: 0 additions & 46 deletions JejuDorang/docker-compose.yml

This file was deleted.

6 changes: 0 additions & 6 deletions JejuDorang/dockerfile

This file was deleted.

43 changes: 43 additions & 0 deletions JejuDorang/src/main/java/JejuDorang/JejuDorang/TestController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package JejuDorang.JejuDorang;

import JejuDorang.JejuDorang.diary.dto.DiaryPublicResponseDto;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
public class TestController {

@Value("${server.env}")
private String env;

@Value("${server.port}")
private String serverPort;

@Value("${server.serverAddress}")
private String serverAddress;

@Value("${serverName}")
private String serverName;

@GetMapping("/hc")
public ResponseEntity<?> heatlthCheck() {
Map<String, String> responseData = new HashMap<>();

responseData.put("serverName", serverName);
responseData.put("serverAddress", serverAddress);
responseData.put("serverPort", serverPort);
responseData.put("env", env);

return ResponseEntity.ok(responseData);
}

@GetMapping("/env")
public ResponseEntity<?> getEnv() {
return ResponseEntity.ok(env);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
Expand All @@ -21,8 +22,11 @@
@RequiredArgsConstructor
public class KakaoService {

@Autowired
private KakaoConfig kakaoConfig;
@Value("${spring.security.oauth2.client.registration.kakao.client-secret}")
private String client_id;

@Value("${spring.security.oauth2.client.registration.kakao.redirect-uri}")
private String redirect_uri;

public KakaoAccessTokenDto getAccessToken(String code) {
// httpHeader 오브젝트 생성
Expand All @@ -32,8 +36,8 @@ public KakaoAccessTokenDto getAccessToken(String code) {
// httpBody 오브젝트 생성
MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
params.add("grant_type", "authorization_code");
params.add("client_id", kakaoConfig.getClientId());
params.add("redirect_uri", kakaoConfig.getRedirectUri());
params.add("client_id", client_id);
params.add("redirect_uri", redirect_uri);
params.add("code", code);

// httpHeader + httpBody
Expand Down
80 changes: 80 additions & 0 deletions JejuDorang/src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,84 @@
spring:
profiles:
active: local
group:
local: local, common
blue: blue, common
green: green, common

server:
env: blue

---

spring:
config:
activate:
on-profile: local
security:
oauth2:
client:
registration:
kakao:
redirect-uri: http://localhost:5173/auth/kakao/callback

server:
port: 8080
serverAddress: localhost

serverName: local_server

---

spring:
config:
activate:
on-profile: blue
security:
oauth2:
client:
registration:
kakao:
redirect-uri: http://3.36.151.149/auth/kakao/callback

server:
port: 8080
serverAddress: 3.36.151.149

serverName: blue_server

---

spring:
config:
activate:
on-profile: green
security:
oauth2:
client:
registration:
kakao:
redirect-uri: http://3.36.151.149/auth/kakao/callback

server:
port: 8081
serverAddress: 3.36.151.149

serverName: green_server

---

# 공통부분
spring:
config:
activate:
on-profile: common
security:
oauth2:
client:
registration:
kakao:
client-secret: ${KAKAO_REST_API_KEY}
jackson:
serialization:
fail-on-empty-beans: false
Expand Down

0 comments on commit 69af0f2

Please sign in to comment.