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

[feat] 배포 설정 #32

Merged
merged 6 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
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, secret
blue: blue, common, secret
green: green, common, secret

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
Loading