diff --git a/JejuDorang/Dockerfile b/JejuDorang/Dockerfile new file mode 100644 index 0000000..aa2bdfd --- /dev/null +++ b/JejuDorang/Dockerfile @@ -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"] \ No newline at end of file diff --git a/JejuDorang/docker-compose.yml b/JejuDorang/docker-compose.yml deleted file mode 100644 index 40344dd..0000000 --- a/JejuDorang/docker-compose.yml +++ /dev/null @@ -1,46 +0,0 @@ -services: - database: - container_name: jejudorang - image: mysql:8.0 - platform: linux/amd64 - environment: - MYSQL_DATABASE: JEJUDORANG_DB - MYSQL_ROOT_HOST: '%' - MYSQL_ROOT_PASSWORD: ${DB_PASSWORD} - TZ: 'Asia/Seoul' - ports: - - "3306:3306" - command: - - "mysqld" - - "--character-set-server=utf8mb4" - - "--collation-server=utf8mb4_unicode_ci" - networks: - - network - healthcheck: - test: [ "CMD-SHELL", "mysqladmin ping -h 127.0.0.1 -p${DB_PASSWORD} --silent" ] - interval: 30s - retries: 5 - start_period: 10s - timeout: 10s - - application: - container_name: main-server - build: - dockerfile: dockerfile - ports: - - "8080:8080" - environment: - SPRING_DATASOURCE_URL: ${DB_URL} - SPRING_DATASOURCE_USERNAME: ${DB_USERNAME} - SPRING_DATASOURCE_PASSWORD: ${DB_PASSWORD} - depends_on: - database: - condition: service_healthy - networks: - - network - env_file: - - .env - -networks: - network: - driver: bridge \ No newline at end of file diff --git a/JejuDorang/dockerfile b/JejuDorang/dockerfile deleted file mode 100644 index 6943249..0000000 --- a/JejuDorang/dockerfile +++ /dev/null @@ -1,6 +0,0 @@ -FROM openjdk:17 -ARG JAR_FILE=build/libs/*.jar -COPY ${JAR_FILE} app.jar -COPY .env ./ -ENV TZ=Asia/Seoul -ENTRYPOINT ["java", "-jar", "/app.jar"] \ No newline at end of file diff --git a/JejuDorang/src/main/java/JejuDorang/JejuDorang/TestController.java b/JejuDorang/src/main/java/JejuDorang/JejuDorang/TestController.java new file mode 100644 index 0000000..47c0432 --- /dev/null +++ b/JejuDorang/src/main/java/JejuDorang/JejuDorang/TestController.java @@ -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 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); + } +} diff --git a/JejuDorang/src/main/java/JejuDorang/JejuDorang/auth/service/KakaoService.java b/JejuDorang/src/main/java/JejuDorang/JejuDorang/auth/service/KakaoService.java index e967022..09e3f10 100644 --- a/JejuDorang/src/main/java/JejuDorang/JejuDorang/auth/service/KakaoService.java +++ b/JejuDorang/src/main/java/JejuDorang/JejuDorang/auth/service/KakaoService.java @@ -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; @@ -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 오브젝트 생성 @@ -32,8 +36,8 @@ public KakaoAccessTokenDto getAccessToken(String code) { // httpBody 오브젝트 생성 MultiValueMap 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 diff --git a/JejuDorang/src/main/resources/application.yml b/JejuDorang/src/main/resources/application.yml index 69524ee..6772967 100644 --- a/JejuDorang/src/main/resources/application.yml +++ b/JejuDorang/src/main/resources/application.yml @@ -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