Skip to content

Commit

Permalink
Merge pull request #36 from team-REDDI/dev
Browse files Browse the repository at this point in the history
dev to main
  • Loading branch information
itsme-shawn authored Jan 30, 2024
2 parents fb802e0 + d69ed93 commit eb86769
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 28 deletions.
34 changes: 17 additions & 17 deletions .github/workflows/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,26 +42,12 @@ jobs:
aws ecr get-login-password --region ap-northeast-2 | docker login --username AWS --password-stdin 533267191976.dkr.ecr.ap-northeast-2.amazonaws.com
docker build -t reddi-server-dev .
docker build --platform amd64 -t reddi-server-dev .
docker tag reddi-server-dev:latest 533267191976.dkr.ecr.ap-northeast-2.amazonaws.com/reddi-server-dev:latest
docker push 533267191976.dkr.ecr.ap-northeast-2.amazonaws.com/reddi-server-dev:latest
- name: (main) Build, tag, and push image to Amazon ECR
if: github.ref == 'refs/heads/main'
run: |
# docker image 빌드
# ECR push
aws ecr get-login-password --region ap-northeast-2 | docker login --username AWS --password-stdin 533267191976.dkr.ecr.ap-northeast-2.amazonaws.com
docker build -t reddi-server .
docker tag reddi-server:latest 533267191976.dkr.ecr.ap-northeast-2.amazonaws.com/reddi-server:latest
docker push 533267191976.dkr.ecr.ap-northeast-2.amazonaws.com/reddi-server:latest
- name: (dev) executing remote ssh commands using password
if: github.ref == 'refs/heads/dev'
uses: appleboy/ssh-action@master
Expand All @@ -77,11 +63,25 @@ jobs:
## docker-compose 실행
sudo chmod 666 /var/run/docker.sock
sudo docker rm -f $(sudo docker ps -q --filter "ancestor=533267191976.dkr.ecr.ap-northeast-2.amazonaws.com/reddi-server-dev:latest" --filter "expose=8081" --filter "expose=6380")
sudo docker rm -f $(sudo docker ps -q --filter "expose=8081" --filter "expose=6380")
docker pull 533267191976.dkr.ecr.ap-northeast-2.amazonaws.com/reddi-server-dev:latest
docker compose -f docker-compose-dev.yml up -d
docker image prune -f
- name: (main) Build, tag, and push image to Amazon ECR
if: github.ref == 'refs/heads/main'
run: |
# docker image 빌드
# ECR push
aws ecr get-login-password --region ap-northeast-2 | docker login --username AWS --password-stdin 533267191976.dkr.ecr.ap-northeast-2.amazonaws.com
docker build --platform amd64 -t reddi-server .
docker tag reddi-server:latest 533267191976.dkr.ecr.ap-northeast-2.amazonaws.com/reddi-server:latest
docker push 533267191976.dkr.ecr.ap-northeast-2.amazonaws.com/reddi-server:latest
- name: (main) executing remote ssh commands using password
if: github.ref == 'refs/heads/main'
uses: appleboy/ssh-action@master
Expand All @@ -98,7 +98,7 @@ jobs:
## docker-compose 실행
sudo chmod 666 /var/run/docker.sock
# sudo docker rm -f $(docker ps -qa)
sudo docker rm -f $(sudo docker ps -q --filter "ancestor=533267191976.dkr.ecr.ap-northeast-2.amazonaws.com/reddi-server:latest" --filter "expose=8080" --filter "expose=6379")
sudo docker rm -f $(sudo docker ps -q --filter "expose=8080" --filter "expose=6379")
docker pull 533267191976.dkr.ecr.ap-northeast-2.amazonaws.com/reddi-server:latest
docker compose -f docker-compose-prod.yml up -d
docker image prune -f
Expand Down
9 changes: 9 additions & 0 deletions deploy_prod.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
./gradlew bootJar

aws ecr get-login-password --region ap-northeast-2 | docker login --username AWS --password-stdin 533267191976.dkr.ecr.ap-northeast-2.amazonaws.com

docker build --platform amd64 -t reddi-server .

docker tag reddi-server:latest 533267191976.dkr.ecr.ap-northeast-2.amazonaws.com/reddi-server:latest

docker push 533267191976.dkr.ecr.ap-northeast-2.amazonaws.com/reddi-server:latest
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ public LoginResponseDto login(String code) {
String refreshToken = jwtTokenProvider.createRefreshToken(payload);

// redis에 저장
// RefreshToken refreshTokenEntity = new RefreshToken();
// refreshTokenEntity.setUserId(member.getId());
// refreshTokenEntity.setRefreshToken(refreshToken);
//
// refreshTokenRepository.save(refreshTokenEntity);
RefreshToken refreshTokenEntity = new RefreshToken();
refreshTokenEntity.setUserId(member.getId());
refreshTokenEntity.setRefreshToken(refreshToken);

refreshTokenRepository.save(refreshTokenEntity);

return LoginResponseDto.builder()
.accessToken(accessToken)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,19 @@
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.servlet.resource.NoResourceFoundException;

@Slf4j
@RestControllerAdvice
public class ApiExceptionHandler {
@ExceptionHandler(NoResourceFoundException.class)
public ResponseEntity<ApiResponse<?>> handleNoResourceFoundException(NoResourceFoundException exception) {
// NoResourceFoundException이 발생했을 때 아무런 처리도 하지 않음
return ResponseEntity.ok().build();
}

@ExceptionHandler(Exception.class)
public ResponseEntity<ApiResponse<?>> handleExceptions(Exception exception) {

log.error("Exception occurred:", exception); // 스택 트레이스 정보를 포함한 로깅

return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(ApiResponse.errorResponse(exception.getMessage()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti
.csrf(csrf -> csrf.disable())
.sessionManagement(sessionManagement ->
sessionManagement.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
.httpBasic(httpBasic -> httpBasic.disable())
.formLogin(formLogin -> formLogin.disable())
// .httpBasic(httpBasic -> httpBasic.disable())
// .formLogin(formLogin -> formLogin.disable())
.authorizeHttpRequests((authorize) -> authorize
.requestMatchers("/static/**", "/resources/**", "/css/**", "/js/**", "/images/**", "/**", "/swagger-ui/**", "/v3/api-docs/**").permitAll()
.requestMatchers("/static/**", "/resources/**", "/css/**", "/js/**", "/images/**").authenticated()
.requestMatchers(HttpMethod.GET, "/**").permitAll()
.requestMatchers(HttpMethod.GET, "/swagger-ui/**").permitAll()
.requestMatchers(HttpMethod.GET, "/v3/api-docs/**").permitAll()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ public class RefreshToken {

@Id
private Long userId;

private String refreshToken;

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,23 @@
import com.example.reddiserver.entity.Post;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.EntityGraph;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;
import java.util.Optional;

public interface BrandRepository extends JpaRepository<Brand, Long> {

@Query("SELECT b FROM Brand b")
// @Query("SELECT b FROM Brand b")
@Query("SELECT b FROM Brand b LEFT JOIN FETCH b.brandTags")
Page<Brand> findAllBrands(Pageable pageable);

@EntityGraph(attributePaths = {"posts"})
Optional<Brand> findById(Long id);

@Query("SELECT b FROM Brand b WHERE b.notion_page_id = :notion_page_id")
Brand findBrandByNotion_page_id(@Param("notion_page_id") String notion_page_id);

Expand Down
1 change: 1 addition & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ spring:
database-platform: org.hibernate.dialect.MySQL8Dialect
show_sql: true
format_sql: true
default_batch_fetch_size: 1000
jwt:
secret: ${JWT_SECRET}
data:
Expand Down

0 comments on commit eb86769

Please sign in to comment.