diff --git a/.github/workflows/gradle-build.yml b/.github/workflows/gradle-build.yml index 0802acfb..8558766b 100644 --- a/.github/workflows/gradle-build.yml +++ b/.github/workflows/gradle-build.yml @@ -77,6 +77,16 @@ jobs: --port ${{ secrets.EC2_SSH_PORT }} \ --cidr ${{ steps.ip.outputs.ipv4 }}/32 + - name: copy file via ssh key + uses: appleboy/scp-action@v0.1.7 + with: + host: ${{ secrets.EC2_HOST }} + username: ${{ secrets.EC2_USERNAME }} + key: ${{ secrets.EC2_KEY }} + port: ${{ secrets.EC2_SSH_PORT }} + source: "./docker-compose.yaml" + target: "./talkka/git/E2E2-TALKKA" + - name: Application Run uses: appleboy/ssh-action@v1.0.3 with: diff --git a/docker-compose.yaml b/docker-compose.yaml index a3b08e2d..4058aa08 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -33,7 +33,7 @@ services: ports: - "8080:8080" environment: - SPRING_DATASOURCE_URL: ${SPRING_DATASOURCE_URL} + SPRING_DATASOURCE_URL: ${MYSQL_URL} SPRING_DATASOURCE_USERNAME: ${MYSQL_USERNAME} SPRING_DATASOURCE_PASSWORD: ${MYSQL_PASSWORD} env_file: diff --git a/server/src/main/java/com/talkka/server/config/SecurityConfig.java b/server/src/main/java/com/talkka/server/config/SecurityConfig.java index 0dcc6028..b72d24d4 100644 --- a/server/src/main/java/com/talkka/server/config/SecurityConfig.java +++ b/server/src/main/java/com/talkka/server/config/SecurityConfig.java @@ -6,6 +6,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.http.HttpMethod; @@ -39,6 +40,9 @@ public class SecurityConfig { private static final Logger log = LoggerFactory.getLogger(SecurityConfig.class); private final CustomOAuth2Service customOAuth2Service; + @Value("${base.url}") + private String baseUrl; + @Bean public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { http @@ -71,7 +75,7 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti ) .logout(logout -> logout .logoutUrl("/api/auth/logout") - .logoutSuccessUrl("http://localhost:3000") + .logoutSuccessUrl(baseUrl) .deleteCookies("JSESSIONID") ) .exceptionHandling(exceptionHandling -> exceptionHandling @@ -90,10 +94,10 @@ public AuthenticationSuccessHandler successHandler() { public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException { if (isUnregisteredUser(authentication)) { - response.sendRedirect("http://localhost:3000/register"); + response.sendRedirect(baseUrl + "/register"); return; } - response.sendRedirect("http://localhost:3000/login/ok"); + response.sendRedirect(baseUrl + "/login/ok"); } private boolean isUnregisteredUser(Authentication authentication) { @@ -114,7 +118,7 @@ public CorsConfigurationSource corsConfigurationSource() { CorsConfiguration config = new CorsConfiguration(); config.setAllowCredentials(true); - config.setAllowedOrigins(List.of("http://localhost:3000")); + config.setAllowedOrigins(List.of(baseUrl)); config.setAllowedMethods(List.of("GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS")); config.setAllowedHeaders(List.of("*")); config.setExposedHeaders(List.of("*")); diff --git a/server/src/main/resources/application.yaml b/server/src/main/resources/application.yaml index 83c88a83..04794dae 100644 --- a/server/src/main/resources/application.yaml +++ b/server/src/main/resources/application.yaml @@ -1,46 +1,12 @@ spring: application: name: talkka-server - datasource: - driver-class-name: com.mysql.cj.jdbc.Driver - url: ${MYSQL_URL} - username: ${MYSQL_USERNAME} - password: ${MYSQL_PASSWORD} - sql: - init: - mode: never # schema.sql 실행시 always 키고 실행하시면 됩니다. - jpa: - hibernate: - ddl-auto: update - properties: - hibernate: - format_sql: true - dialect: org.hibernate.dialect.MySQL8Dialect - show-sql: true - security: - oauth2: - client: - registration: - naver: - client-id: ${NAVER_CLIENT_ID} - client-secret: ${NAVER_CLINET_SECRET} - redirect_uri: http://localhost:8080/api/auth/login/naver/code - client-name: Naver - authorization-grant-type: authorization_code - scope: - - name - - email - provider: - naver: - authorization-uri: https://nid.naver.com/oauth2.0/authorize - token-uri: https://nid.naver.com/oauth2.0/token - user-info-uri: https://openapi.naver.com/v1/nid/me - user-name-attribute: response + profiles: + active: prod # 개발 환경에 따라 변경할 것 (local | prod) thymeleaf: prefix: classpath:/templates/ suffix: .html - openapi: public: bus: @@ -48,7 +14,6 @@ openapi: keys: - ${SERVICE_KEY_1} - bus: location: collect: @@ -82,4 +47,89 @@ springdoc: api-docs: path: /api-docs default-consumes-media-type: application/json +--- +spring: + config: + activate: + on-profile: local + datasource: + driver-class-name: com.mysql.cj.jdbc.Driver + url: ${MYSQL_URL} + username: ${MYSQL_USERNAME} + password: ${MYSQL_PASSWORD} + sql: + init: + mode: never # schema.sql 실행시 always 키고 실행하시면 됩니다. + jpa: + hibernate: + ddl-auto: validate + properties: + hibernate: + format_sql: true + dialect: org.hibernate.dialect.MySQL8Dialect + show-sql: true + security: + oauth2: + client: + registration: + naver: + client-id: ${NAVER_CLIENT_ID} + client-secret: ${NAVER_CLIENT_SECRET} + redirect_uri: http://localhost:8080/api/auth/login/naver/code + client-name: Naver + authorization-grant-type: authorization_code + scope: + - name + - email + provider: + naver: + authorization-uri: https://nid.naver.com/oauth2.0/authorize + token-uri: https://nid.naver.com/oauth2.0/token + user-info-uri: https://openapi.naver.com/v1/nid/me + user-name-attribute: response + +base: + url: http://localhost:3000 +--- +spring: + config: + activate: + on-profile: prod + datasource: + driver-class-name: com.mysql.cj.jdbc.Driver + url: ${MYSQL_URL} + username: ${MYSQL_USERNAME} + password: ${MYSQL_PASSWORD} + sql: + init: + mode: never + jpa: + hibernate: + ddl-auto: update + properties: + hibernate: + format_sql: true + dialect: org.hibernate.dialect.MySQL8Dialect + show-sql: false + security: + oauth2: + client: + registration: + naver: + client-id: ${NAVER_CLIENT_ID} + client-secret: ${NAVER_CLIENT_SECRET} + redirect_uri: https://talkka-bus/api/auth/login/naver/code + client-name: Naver + authorization-grant-type: authorization_code + scope: + - name + - email + provider: + naver: + authorization-uri: https://nid.naver.com/oauth2.0/authorize + token-uri: https://nid.naver.com/oauth2.0/token + user-info-uri: https://openapi.naver.com/v1/nid/me + user-name-attribute: response +base: + url: https://talkka-bus:3000 # 추후 프론트에 맞게 수정 필요 \ No newline at end of file