Skip to content

Commit

Permalink
Merge pull request #132 from kakao-tech-campus-2nd-step3/weekly/10
Browse files Browse the repository at this point in the history
[Develop] 10주차 PR
  • Loading branch information
sanghee0820 authored Nov 8, 2024
2 parents 914a6f4 + 4910280 commit ab3dc12
Show file tree
Hide file tree
Showing 114 changed files with 2,979 additions and 625 deletions.
80 changes: 63 additions & 17 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
# Docker Hub 이미지 푸시
- name: docker Hub push
run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/inplace


# 위 과정에서 푸시한 이미지를 ec2에서 풀받아서 실행시키는 과정
run-docker-image-on-ec2:
Expand All @@ -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
10 changes: 4 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand All @@ -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'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class QFavoriteInfluencer extends EntityPathBase<FavoriteInfluencer> {

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;

Expand Down
45 changes: 45 additions & 0 deletions src/main/generated/team7/inplace/global/exception/QErrorLog.java
Original file line number Diff line number Diff line change
@@ -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<ErrorLog> {

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<Long> 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<? extends ErrorLog> path) {
super(path.getType(), path.getMetadata());
}

public QErrorLog(PathMetadata metadata) {
super(ErrorLog.class, metadata);
}

}

Original file line number Diff line number Diff line change
@@ -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<LikedPlace> {

private static final long serialVersionUID = 1786130640L;

private static final PathInits INITS = PathInits.DIRECT2;

public static final QLikedPlace likedPlace = new QLikedPlace("likedPlace");

public final NumberPath<Long> 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<? extends LikedPlace> 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<? extends LikedPlace> 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;
}

}

Original file line number Diff line number Diff line change
@@ -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<OauthToken> {

private static final long serialVersionUID = -59028672L;

private static final PathInits INITS = PathInits.DIRECT2;

public static final QOauthToken oauthToken1 = new QOauthToken("oauthToken1");

public final DateTimePath<java.time.LocalDateTime> expiresAt = createDateTime("expiresAt", java.time.LocalDateTime.class);

public final NumberPath<Long> 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<? extends OauthToken> 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<? extends OauthToken> type, PathMetadata metadata, PathInits inits) {
super(type, metadata, inits);
this.user = inits.isInitialized("user") ? new team7.inplace.user.domain.QUser(forProperty("user")) : null;
}

}

2 changes: 2 additions & 0 deletions src/main/generated/team7/inplace/place/domain/QPlace.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public class QPlace extends EntityPathBase<Place> {

public final NumberPath<Long> id = createNumber("id", Long.class);

public final ListPath<String, StringPath> menuboardphotourlList = this.<String, StringPath>createList("menuboardphotourlList", String.class, StringPath.class, PathInits.DIRECT2);

public final StringPath menuImgUrl = createString("menuImgUrl");

public final ListPath<Menu, QMenu> menus = this.<Menu, QMenu>createList("menus", Menu.class, QMenu.class, PathInits.DIRECT2);
Expand Down
60 changes: 60 additions & 0 deletions src/main/generated/team7/inplace/review/domain/QReview.java
Original file line number Diff line number Diff line change
@@ -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<Review> {

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<java.util.Date> createdDate = createDateTime("createdDate", java.util.Date.class);

public final NumberPath<Long> 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<? extends Review> 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<? extends Review> 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;
}

}

4 changes: 4 additions & 0 deletions src/main/generated/team7/inplace/video/domain/QVideo.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ public class QVideo extends EntityPathBase<Video> {

public final StringPath videoUrl = createString("videoUrl");

public final NumberPath<Long> viewCount = createNumber("viewCount", Long.class);

public final NumberPath<Long> viewCountIncrease = createNumber("viewCountIncrease", Long.class);

public QVideo(String variable) {
this(Video.class, forVariable(variable), INITS);
}
Expand Down
Loading

0 comments on commit ab3dc12

Please sign in to comment.