diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index cfd0dff3..1644596c 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -50,7 +50,7 @@ jobs: # Docker Hub 이미지 푸시 - name: docker Hub push run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/inplace - + # 위 과정에서 푸시한 이미지를 ec2에서 풀받아서 실행시키는 과정 run-docker-image-on-ec2: @@ -68,30 +68,76 @@ jobs: # 최신 이미지를 pull - name: docker pull run: sudo docker pull ${{ secrets.DOCKERHUB_USERNAME }}/inplace - - # 기존의 컨테이너를 중지 - - name: docker stop container - run: sudo docker stop $(sudo docker ps -q) 2>/dev/null || true + + # 현재 실행 중인 버전을 확인 + - name: Check current active container + id: check_version + run: | + CURRENT_VERSION=$(sudo docker ps --format "{{.Names}}" | grep -oE "inplace-(blue|green)" || echo "") + if [[ -z "$CURRENT_VERSION" ]]; then + echo "No active container found" + echo "current_version=none" >> $GITHUB_ENV + else + CURRENT_VERSION=$(echo "$CURRENT_VERSION" | grep -oE "(blue|green)") + echo "Current running version is $CURRENT_VERSION" + echo "current_version=${CURRENT_VERSION}" >> $GITHUB_ENV + fi + + # 다음 배포 버전을 결정 + - name: Set next version + run: | + if [[ "${{ env.current_version }}" == "blue" ]]; then + NEXT_VERSION="green" + PORT=8081 + else + NEXT_VERSION="blue" + PORT=8080 + fi + echo "Next version to deploy is inplace-${NEXT_VERSION}" + echo "next_version=${NEXT_VERSION}" >> $GITHUB_ENV + echo "port=${PORT}" >> $GITHUB_ENV + + # 기존의 동일한 컨테이너를 중지 (블루/그린 중 다음 배포 타겟에 해당하는 컨테이너) + - name: Stop current docker container + run: | + echo "Stopping container inplace-${{ env.next_version }}" + sudo docker stop inplace-${{ env.next_version }} || true + sudo docker rm inplace-${{ env.next_version }} || true # .env 파일 생성 - name: Create .env file run: | + rm -f .env echo "${{ secrets.ENV }}" >> .env - # 브랜치에 따라 다른 환경 변수를 설정하여 컨테이너 실행 - # - name: docker run new container - # run: | - # if [ "${{ github.ref }}" == "refs/heads/Master" ]; then - # sudo docker run --name inplace --rm -d -p 8080:8080 --env-file .env ${{ secrets.DOCKERHUB_USERNAME }}/inplace - # elif [ "${{ github.ref }}" == "refs/heads/develop" ]; then - # sudo docker run --name inplace-dev --rm -d -p 8081:8080 --env-file .env ${{ secrets.DOCKERHUB_USERNAME }}/inplace - # fi - - # weekly/* 브랜치 8081 포트로 설정 - - name: docker run new container + # 다음 버전으로 새 컨테이너를 실행 + - name: Run New Container on Next Version run: | - sudo docker run --name inplace-dev --rm -d -p 8081:8080 --env-file .env ${{ secrets.DOCKERHUB_USERNAME }}/inplace + echo "Running new container inplace-${{ env.next_version }}" + sudo docker run --name "inplace-${{ env.next_version }}" --rm -d -p ${{ env.port }}:8080 --env-file .env ${{ secrets.DOCKERHUB_USERNAME }}/inplace + # 로드 밸런서 타겟 그룹을 업데이트하여 트래픽을 새 컨테이너로 전환합니다. + - name: Update Load Balancer Target Group + run: | + TARGET_GROUP_ARN_BLUE="${{ secrets.TARGET_GROUP_ARN_8080 }}" + TARGET_GROUP_ARN_GREEN="${{ secrets.TARGET_GROUP_ARN_8081 }}" + if [[ "${{ env.next_version }}" == "blue" ]]; then + aws elbv2 modify-listener --listener-arn ${{ secrets.LISTENER_ARN_443 }} --default-actions Type=forward,TargetGroupArn=$TARGET_GROUP_ARN_BLUE + else + aws elbv2 modify-listener --listener-arn ${{ secrets.LISTENER_ARN_443 }} --default-actions Type=forward,TargetGroupArn=$TARGET_GROUP_ARN_GREEN + fi + + # 이전 컨테이너 정리 + - name: Remove previous docker container + run: | + if [[ "${{ env.current_version }}" != "none" ]]; then + echo "Removing previous container inplace-${{ env.current_version }}" + sudo docker stop inplace-${{ env.current_version }} || true + sudo docker rm inplace-${{ env.current_version }} || true + else + echo "No active container to remove" + fi + # 미사용 이미지를 정리 - name: delete old docker image run: sudo docker system prune -f diff --git a/build.gradle b/build.gradle index b1dbd6a7..37c3cf6d 100644 --- a/build.gradle +++ b/build.gradle @@ -27,6 +27,8 @@ dependencies { //Spring implementation 'org.springframework.boot:spring-boot-starter-web' + implementation 'org.springframework.boot:spring-boot-starter-webflux' + testImplementation 'io.projectreactor:reactor-test' compileOnly 'org.projectlombok:lombok' annotationProcessor 'org.projectlombok:lombok' @@ -53,15 +55,11 @@ dependencies { annotationProcessor "jakarta.annotation:jakarta.annotation-api" annotationProcessor "jakarta.persistence:jakarta.persistence-api" - + // Test testImplementation 'org.springframework.boot:spring-boot-starter-test' testRuntimeOnly 'org.junit.platform:junit-platform-launcher' - implementation 'com.querydsl:querydsl-jpa:5.0.0:jakarta' - annotationProcessor "com.querydsl:querydsl-apt:5.0.0:jakarta" - annotationProcessor "jakarta.annotation:jakarta.annotation-api" - annotationProcessor "jakarta.persistence:jakarta.persistence-api" - + // Thymeleaf implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' implementation 'org.springframework.boot:spring-boot-starter-web' } diff --git a/src/main/generated/team7/inplace/favoriteInfluencer/domain/QFavoriteInfluencer.java b/src/main/generated/team7/inplace/favoriteInfluencer/domain/QFavoriteInfluencer.java index a0ddba4b..ae4ab9f7 100644 --- a/src/main/generated/team7/inplace/favoriteInfluencer/domain/QFavoriteInfluencer.java +++ b/src/main/generated/team7/inplace/favoriteInfluencer/domain/QFavoriteInfluencer.java @@ -26,7 +26,7 @@ public class QFavoriteInfluencer extends EntityPathBase { public final team7.inplace.influencer.domain.QInfluencer influencer; - public final BooleanPath like = createBoolean("like"); + public final BooleanPath isLiked = createBoolean("isLiked"); public final team7.inplace.user.domain.QUser user; diff --git a/src/main/generated/team7/inplace/global/exception/QErrorLog.java b/src/main/generated/team7/inplace/global/exception/QErrorLog.java new file mode 100644 index 00000000..ceffad2a --- /dev/null +++ b/src/main/generated/team7/inplace/global/exception/QErrorLog.java @@ -0,0 +1,45 @@ +package team7.inplace.global.exception; + +import static com.querydsl.core.types.PathMetadataFactory.*; + +import com.querydsl.core.types.dsl.*; + +import com.querydsl.core.types.PathMetadata; +import javax.annotation.processing.Generated; +import com.querydsl.core.types.Path; + + +/** + * QErrorLog is a Querydsl query type for ErrorLog + */ +@Generated("com.querydsl.codegen.DefaultEntitySerializer") +public class QErrorLog extends EntityPathBase { + + private static final long serialVersionUID = 50351046L; + + public static final QErrorLog errorLog = new QErrorLog("errorLog"); + + public final StringPath errorMessage = createString("errorMessage"); + + public final StringPath errorUrl = createString("errorUrl"); + + public final NumberPath id = createNumber("id", Long.class); + + public final BooleanPath isResolved = createBoolean("isResolved"); + + public final StringPath stackTrace = createString("stackTrace"); + + public QErrorLog(String variable) { + super(ErrorLog.class, forVariable(variable)); + } + + public QErrorLog(Path path) { + super(path.getType(), path.getMetadata()); + } + + public QErrorLog(PathMetadata metadata) { + super(ErrorLog.class, metadata); + } + +} + diff --git a/src/main/generated/team7/inplace/likedPlace/domain/QLikedPlace.java b/src/main/generated/team7/inplace/likedPlace/domain/QLikedPlace.java new file mode 100644 index 00000000..3657f5a9 --- /dev/null +++ b/src/main/generated/team7/inplace/likedPlace/domain/QLikedPlace.java @@ -0,0 +1,59 @@ +package team7.inplace.likedPlace.domain; + +import static com.querydsl.core.types.PathMetadataFactory.*; + +import com.querydsl.core.types.dsl.*; + +import com.querydsl.core.types.PathMetadata; +import javax.annotation.processing.Generated; +import com.querydsl.core.types.Path; +import com.querydsl.core.types.dsl.PathInits; + + +/** + * QLikedPlace is a Querydsl query type for likedPlace + */ +@Generated("com.querydsl.codegen.DefaultEntitySerializer") +public class QLikedPlace extends EntityPathBase { + + private static final long serialVersionUID = 1786130640L; + + private static final PathInits INITS = PathInits.DIRECT2; + + public static final QLikedPlace likedPlace = new QLikedPlace("likedPlace"); + + public final NumberPath id = createNumber("id", Long.class); + + public final BooleanPath isLiked = createBoolean("isLiked"); + + public final team7.inplace.place.domain.QPlace place; + + public final team7.inplace.user.domain.QUser user; + + public QLikedPlace(String variable) { + this(LikedPlace.class, forVariable(variable), INITS); + } + + public QLikedPlace(Path path) { + this(path.getType(), path.getMetadata(), PathInits.getFor(path.getMetadata(), INITS)); + } + + public QLikedPlace(PathMetadata metadata) { + this(metadata, PathInits.getFor(metadata, INITS)); + } + + public QLikedPlace(PathMetadata metadata, PathInits inits) { + this(LikedPlace.class, metadata, inits); + } + + public QLikedPlace(Class type, PathMetadata metadata, PathInits inits) { + super(type, metadata, inits); + this.place = inits.isInitialized("place") ? new team7.inplace.place.domain.QPlace( + forProperty("place"), inits.get("place")) : null; + this.user = + inits.isInitialized("user") ? new team7.inplace.user.domain.QUser(forProperty("user")) + : null; + } + +} + diff --git a/src/main/generated/team7/inplace/oauthToken/domain/QOauthToken.java b/src/main/generated/team7/inplace/oauthToken/domain/QOauthToken.java new file mode 100644 index 00000000..9ae83875 --- /dev/null +++ b/src/main/generated/team7/inplace/oauthToken/domain/QOauthToken.java @@ -0,0 +1,55 @@ +package team7.inplace.oauthToken.domain; + +import static com.querydsl.core.types.PathMetadataFactory.*; + +import com.querydsl.core.types.dsl.*; + +import com.querydsl.core.types.PathMetadata; +import javax.annotation.processing.Generated; +import com.querydsl.core.types.Path; +import com.querydsl.core.types.dsl.PathInits; + + +/** + * QOauthToken is a Querydsl query type for OauthToken + */ +@Generated("com.querydsl.codegen.DefaultEntitySerializer") +public class QOauthToken extends EntityPathBase { + + private static final long serialVersionUID = -59028672L; + + private static final PathInits INITS = PathInits.DIRECT2; + + public static final QOauthToken oauthToken1 = new QOauthToken("oauthToken1"); + + public final DateTimePath expiresAt = createDateTime("expiresAt", java.time.LocalDateTime.class); + + public final NumberPath id = createNumber("id", Long.class); + + public final StringPath oauthToken = createString("oauthToken"); + + public final team7.inplace.user.domain.QUser user; + + public QOauthToken(String variable) { + this(OauthToken.class, forVariable(variable), INITS); + } + + public QOauthToken(Path path) { + this(path.getType(), path.getMetadata(), PathInits.getFor(path.getMetadata(), INITS)); + } + + public QOauthToken(PathMetadata metadata) { + this(metadata, PathInits.getFor(metadata, INITS)); + } + + public QOauthToken(PathMetadata metadata, PathInits inits) { + this(OauthToken.class, metadata, inits); + } + + public QOauthToken(Class type, PathMetadata metadata, PathInits inits) { + super(type, metadata, inits); + this.user = inits.isInitialized("user") ? new team7.inplace.user.domain.QUser(forProperty("user")) : null; + } + +} + diff --git a/src/main/generated/team7/inplace/place/domain/QPlace.java b/src/main/generated/team7/inplace/place/domain/QPlace.java index 707b39b6..26dba19b 100644 --- a/src/main/generated/team7/inplace/place/domain/QPlace.java +++ b/src/main/generated/team7/inplace/place/domain/QPlace.java @@ -32,6 +32,8 @@ public class QPlace extends EntityPathBase { public final NumberPath id = createNumber("id", Long.class); + public final ListPath menuboardphotourlList = this.createList("menuboardphotourlList", String.class, StringPath.class, PathInits.DIRECT2); + public final StringPath menuImgUrl = createString("menuImgUrl"); public final ListPath menus = this.createList("menus", Menu.class, QMenu.class, PathInits.DIRECT2); diff --git a/src/main/generated/team7/inplace/review/domain/QReview.java b/src/main/generated/team7/inplace/review/domain/QReview.java new file mode 100644 index 00000000..16e6939b --- /dev/null +++ b/src/main/generated/team7/inplace/review/domain/QReview.java @@ -0,0 +1,60 @@ +package team7.inplace.review.domain; + +import static com.querydsl.core.types.PathMetadataFactory.*; + +import com.querydsl.core.types.dsl.*; + +import com.querydsl.core.types.PathMetadata; +import javax.annotation.processing.Generated; +import com.querydsl.core.types.Path; +import com.querydsl.core.types.dsl.PathInits; + + +/** + * QReview is a Querydsl query type for Review + */ +@Generated("com.querydsl.codegen.DefaultEntitySerializer") +public class QReview extends EntityPathBase { + + private static final long serialVersionUID = 978169644L; + + private static final PathInits INITS = PathInits.DIRECT2; + + public static final QReview review = new QReview("review"); + + public final StringPath comment = createString("comment"); + + public final DateTimePath createdDate = createDateTime("createdDate", java.util.Date.class); + + public final NumberPath id = createNumber("id", Long.class); + + public final BooleanPath isLiked = createBoolean("isLiked"); + + public final team7.inplace.place.domain.QPlace place; + + public final team7.inplace.user.domain.QUser user; + + public QReview(String variable) { + this(Review.class, forVariable(variable), INITS); + } + + public QReview(Path path) { + this(path.getType(), path.getMetadata(), PathInits.getFor(path.getMetadata(), INITS)); + } + + public QReview(PathMetadata metadata) { + this(metadata, PathInits.getFor(metadata, INITS)); + } + + public QReview(PathMetadata metadata, PathInits inits) { + this(Review.class, metadata, inits); + } + + public QReview(Class type, PathMetadata metadata, PathInits inits) { + super(type, metadata, inits); + this.place = inits.isInitialized("place") ? new team7.inplace.place.domain.QPlace(forProperty("place"), inits.get("place")) : null; + this.user = inits.isInitialized("user") ? new team7.inplace.user.domain.QUser(forProperty("user")) : null; + } + +} + diff --git a/src/main/generated/team7/inplace/video/domain/QVideo.java b/src/main/generated/team7/inplace/video/domain/QVideo.java index 94a00c3f..2ca3c32f 100644 --- a/src/main/generated/team7/inplace/video/domain/QVideo.java +++ b/src/main/generated/team7/inplace/video/domain/QVideo.java @@ -30,6 +30,10 @@ public class QVideo extends EntityPathBase