diff --git a/JejuDorang/Dockerfile b/JejuDorang/Dockerfile index aa2bdfd..6943249 100644 --- a/JejuDorang/Dockerfile +++ b/JejuDorang/Dockerfile @@ -1,7 +1,6 @@ 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 +ENV TZ=Asia/Seoul +ENTRYPOINT ["java", "-jar", "/app.jar"] \ No newline at end of file diff --git a/JejuDorang/docker-compose.yml b/JejuDorang/docker-compose.yml new file mode 100644 index 0000000..40344dd --- /dev/null +++ b/JejuDorang/docker-compose.yml @@ -0,0 +1,46 @@ +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/src/main/java/JejuDorang/JejuDorang/auth/service/KakaoService.java b/JejuDorang/src/main/java/JejuDorang/JejuDorang/auth/service/KakaoService.java index 09e3f10..c274029 100644 --- a/JejuDorang/src/main/java/JejuDorang/JejuDorang/auth/service/KakaoService.java +++ b/JejuDorang/src/main/java/JejuDorang/JejuDorang/auth/service/KakaoService.java @@ -22,11 +22,8 @@ @RequiredArgsConstructor public class KakaoService { - @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; + @Autowired + private final KakaoConfig kakaoConfig; public KakaoAccessTokenDto getAccessToken(String code) { // httpHeader 오브젝트 생성 @@ -36,8 +33,8 @@ public KakaoAccessTokenDto getAccessToken(String code) { // httpBody 오브젝트 생성 MultiValueMap params = new LinkedMultiValueMap<>(); params.add("grant_type", "authorization_code"); - params.add("client_id", client_id); - params.add("redirect_uri", redirect_uri); + params.add("client_id", kakaoConfig.getClientId()); + params.add("redirect_uri", kakaoConfig.getRedirectUri()); params.add("code", code); // httpHeader + httpBody diff --git a/JejuDorang/src/main/java/JejuDorang/JejuDorang/config/SecurityConfig.java b/JejuDorang/src/main/java/JejuDorang/JejuDorang/config/SecurityConfig.java index 045c80e..212b977 100644 --- a/JejuDorang/src/main/java/JejuDorang/JejuDorang/config/SecurityConfig.java +++ b/JejuDorang/src/main/java/JejuDorang/JejuDorang/config/SecurityConfig.java @@ -35,8 +35,8 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { .authorizeHttpRequests(authz -> authz .requestMatchers(CorsUtils::isPreFlightRequest).permitAll() .requestMatchers("/auth/kakao/**").permitAll() // /auth/kakao/ 경로만 접근 허용 -// .anyRequest().authenticated()) // 나머지 요청은 인증 필요 - .anyRequest().permitAll()) + .anyRequest().authenticated()) // 나머지 요청은 인증 필요 +// .anyRequest().permitAll()) .addFilterBefore(new JwtAuthFilter(jwtTokenProvider), UsernamePasswordAuthenticationFilter.class); return http.build(); // SecurityFilterChain 반환 diff --git a/JejuDorang/src/main/resources/application.yml b/JejuDorang/src/main/resources/application.yml index 6772967..69524ee 100644 --- a/JejuDorang/src/main/resources/application.yml +++ b/JejuDorang/src/main/resources/application.yml @@ -1,84 +1,4 @@ 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