Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Deploy]: 운영서버 배포 24/02/21 #23

Merged
merged 73 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
afb79c3
chore: allopen 플러그인 설정
twoosky Jan 2, 2024
9d4dbbe
feat: comment 도메인 생성
twoosky Jan 2, 2024
07d7145
feat: like 도메인 작성
twoosky Jan 2, 2024
95635a5
feat: userId value class 구현
twoosky Jan 2, 2024
9134ac4
feat: comment 엔티티 작성
twoosky Jan 2, 2024
9af0980
feat: comment 생성(댓글/대댓글) 비즈니스 로직 구현
twoosky Jan 2, 2024
7c9237e
feat: comment readModel dto 생성
twoosky Jan 2, 2024
b4f91e7
feat: comment output port 정의
twoosky Jan 9, 2024
2a57644
feat: 댓글 삭제 비즈니스 로직 구현
twoosky Jan 9, 2024
32eec34
feat: 댓글 생성 비즈니스 로직 구현
twoosky Jan 9, 2024
4540479
feat: comment 관련 request, response dto 작성
twoosky Jan 9, 2024
d4a0cab
feat: 댓글 조회 비즈니스 로직 구현
twoosky Jan 9, 2024
4ea5a97
feat: 댓글에 대한 좋아요 생성/삭제 비즈니스 로직 구현
twoosky Jan 9, 2024
1f65737
feat: comment 도메인 작성
twoosky Jan 9, 2024
e8c469d
feat: comment 좋아요 도메인 작성
twoosky Jan 9, 2024
fb50788
feat: 공통 exception 인터페이스 구현
twoosky Jan 9, 2024
95ce348
chore: 기본 생성자 생성 플러그인 추가
twoosky Jan 9, 2024
6541a06
feat: errorCode, baseException 정의
twoosky Jan 11, 2024
77360eb
comment, commentlIke 도메인, exception 정의
twoosky Jan 11, 2024
761bb40
feat: 임시 user 도메인 정의
twoosky Jan 11, 2024
92981d3
fix: article, category exception이 의존하는 errorCode객체명 변경
twoosky Jan 11, 2024
19312d9
feat: 부모, 자식 댓글 생성 비즈니스로직 구현
twoosky Jan 11, 2024
d0b63f0
feat: 댓글 삭제 비즈니스 로직 구현
twoosky Jan 11, 2024
1b93a88
feat: article에 대한 댓글 조회 비즈니스 로직 구현
twoosky Jan 11, 2024
fed5c90
feat: 댓글에 대한 좋아요 upsert 비즈니스 로직 구현
twoosky Jan 11, 2024
9317679
feat: comment request, response 정의 및 readModel dto 정의
twoosky Jan 11, 2024
ddfd3f8
feat: comment output port 정의
twoosky Jan 11, 2024
5c5e552
feat: comment entity 구현
twoosky Jan 11, 2024
9322548
feat: comment 좋아요 entity 구현
twoosky Jan 11, 2024
61f5ecb
feat: entityManager 및 jpaQueryFactory 빈 등록
twoosky Jan 11, 2024
f15a071
feat: comment readmodel 정의 (infra)
twoosky Jan 11, 2024
53b7ef4
feat: comment, commentLike entity, domain mapper 구현
twoosky Jan 11, 2024
e6f9a5e
feat: comment save, delete adapter 구현
twoosky Jan 11, 2024
47b1da1
feat: comment 전체 조회 adapter 구현
twoosky Jan 11, 2024
7ad05a0
feat: commentLike save, update adapter 구현
twoosky Jan 11, 2024
55c5f2a
feat: comment like 조회 adapter 구현
twoosky Jan 11, 2024
56bd7e0
feat: comment, commentLike repository 정의 및 commentCustomeRepository 구현
twoosky Jan 11, 2024
6d400f6
feat: comment, comment like crud api 구현
twoosky Jan 11, 2024
5e82489
fix: base exception 객체명 수정
twoosky Jan 11, 2024
0bf31c9
chore: querydsl 설정
twoosky Jan 11, 2024
e3d7a71
chore: querydsl gradle 설정
jihwan2da Jan 16, 2024
052cc3f
feat: Article 페이징 쿼리 작성
jihwan2da Jan 16, 2024
2a47922
chore: rebase 시 충돌 잘못 수정 오류 해결
jihwan2da Jan 22, 2024
e89747e
fix: 댓글 model(domain, db) 재설계
jihwan2da Jan 22, 2024
65539c5
fix: 댓글(부모, 자식) 생성 API 로직 수정
jihwan2da Jan 22, 2024
3efadfb
fix: 기존 댓글 조회 로직들 삭제
jihwan2da Jan 22, 2024
d71d2b5
fix: 필요없는 파일 삭제
jihwan2da Jan 22, 2024
7f46d9f
feat, refactor: 부모 댓글 조회 API 로직 구현 및 공통 코드 머지
jihwan2da Jan 22, 2024
305f988
refactor: ErrCode, Exception 흩어져 있는 코드 리팩토링
jihwan2da Jan 22, 2024
c1169c6
feat: Comment 도메인 삭제 행위 메소드 작성
jihwan2da Jan 23, 2024
5b5c642
feat: Comment 행위(생성, 삭제) 도메인 이벤트 정의
jihwan2da Jan 23, 2024
18d4887
fix: 댓글 삭제 트랜잭션 로직 변경
jihwan2da Jan 23, 2024
359137f
fix: 댓글 삭제 로직 변경에 따른 Controller 변경
jihwan2da Jan 23, 2024
09b473b
feat: Article 댓글 추가 행위 메소드 추가
jihwan2da Jan 23, 2024
84839e5
feat: Article 댓글 upsert usecase 작성
jihwan2da Jan 23, 2024
29f3d3d
feat: ArticleApplicationEventHandler 생성 및 댓글 생성,삭제 이벤트 핸들러 구현
jihwan2da Jan 23, 2024
e0414bd
feat: Comment 자식 댓글 upsert usecase 작성
jihwan2da Jan 23, 2024
6351fe8
feat: CommentApplicationEventHandler 생성 및 자식 댓글 삭제 이벤트 핸들러 구현
jihwan2da Jan 23, 2024
f6b0a96
feat: 자식 댓글 생성 이벤트 publish 및 handle
jihwan2da Jan 23, 2024
9af2545
feat: 자식 댓글 상세 조회 쿼리 작성 및 db read 모델 생성
jihwan2da Jan 23, 2024
e47bd11
feat: 자식 댓글 조회 readModel 정의
jihwan2da Jan 23, 2024
fbc7fa8
feat: 자식 댓글 조회 service 구현
jihwan2da Jan 23, 2024
057f8bb
feat: 자식 댓글 조회 controller 구현
jihwan2da Jan 23, 2024
77900ea
refactor: 부모 댓글 조회 Request 파일명 변경
jihwan2da Jan 23, 2024
6d239dc
fix: 댓글 좋아요 upsert 로직 수정
jihwan2da Jan 23, 2024
33fcc85
rename: CommentController -> CommentCommandController
jihwan2da Jan 23, 2024
5f98b59
fix: 게시글 상세 조회 시 작성자 정보 오류 수정
jihwan2da Jan 23, 2024
5694219
chore: querydsl gradle 중복 설정 제거
jihwan2da Jan 23, 2024
0066f52
Merge pull request #9 from gloddy-dev/feat/#2
jihwan2da Jan 23, 2024
a9523e5
fix: EC2 -> Fargate에 따른 ECS 태스크 정의 및 Dockerfile 수정
jihwan2da Feb 19, 2024
e6b9110
Merge pull request #18 from gloddy-dev/infra/#16,17
jihwan2da Feb 19, 2024
12642a3
[Feat, Infra]: 운영 배포 환경 구축 (#19)
jihwan2da Feb 21, 2024
f3e435e
[Fix]: LocalDateTime Response 포맷터 변경(12시간제 -> 24시간제) (#22)
jihwan2da Feb 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 86 additions & 0 deletions .github/workflows/DeployOnPRD.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: Deploy on STG Server (Amazon ECS)

on:
pull_request:
types: [closed]
branches: [release]

env:
AWS_REGION: ap-northeast-2
ECR_REPOSITORY: community-prd
ECS_SERVICE: community-service
ECS_CLUSTER: gloddy-ecs-prd
ECS_TASK_DEFINITION: task-definition-prd.json

CONTAINER_NAME: springboot

permissions:
contents: read

jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest
environment: production

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

- uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-

- name: Grant execute permission for gradlew
run: chmod +x ./gradlew

- name: Build with Gradle
run: ./gradlew clean :bootstrap:bootJar

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ECS_ACCESS }}
aws-secret-access-key: ${{ secrets.AWS_ECS_SECRET }}
aws-region: ${{ env.AWS_REGION }}

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1

- name: Build, tag, and push image to Amazon ECR
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
IMAGE_TAG: latest
run: |
docker build -f Dockerfile_PRD -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT

- name: Fill in the new image ID in the Amazon ECS task definition
id: task-def
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: ${{ env.ECS_TASK_DEFINITION }}
container-name: ${{ env.CONTAINER_NAME }}
image: ${{ steps.build-image.outputs.image }}

- name: Deploy Amazon ECS task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
task-definition: ${{ steps.task-def.outputs.task-definition }}
service: ${{ env.ECS_SERVICE }}
cluster: ${{ env.ECS_CLUSTER }}
wait-for-service-stability: true
2 changes: 1 addition & 1 deletion .github/workflows/DeployOnSTG.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Deploy on STG Server (Amazon ECS)
name: Deploy on PRD Server (Amazon ECS)

on:
pull_request:
Expand Down
17 changes: 17 additions & 0 deletions Dockerfile_PRD
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM openjdk:17.0-slim

ARG PROJECT_DIRECTORY=/build
WORKDIR $PROJECT_DIRECTORY

ARG JAR_FILE_PATH=bootstrap/build/libs/bootstrap-0.0.1-SNAPSHOT.jar
COPY ${JAR_FILE_PATH} app.jar

ENV TZ=Asia/Seoul

EXPOSE 8080

RUN apt-get update && apt-get install -y curl wget \
&& wget -O dd-java-agent.jar 'https://dtdg.co/latest-java-tracer' \
&& rm -rf /var/lib/apt/lists/*

ENTRYPOINT ["java", "-javaagent:dd-java-agent.jar", "-Ddd.profiling.enabled=true", "-XX:FlightRecorderOptions=stackdepth=256", "-Ddd.appsec.enabled=true", "-Ddd.iast.enabled=true", "-Ddd.logs.injection=true", "-Ddd.jmxfetch.enabled=true", "-Ddd.service=gloddy-community", "-Ddd.env=production", "-jar", "app.jar"]
2 changes: 1 addition & 1 deletion Dockerfile_STG
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ RUN apt-get update && apt-get install -y curl wget \
&& wget -O dd-java-agent.jar 'https://dtdg.co/latest-java-tracer' \
&& rm -rf /var/lib/apt/lists/*

ENTRYPOINT ["sh", "-c", "export TOKEN=$(curl -X PUT \"http://169.254.169.254/latest/api/token\" -H \"X-aws-ec2-metadata-token-ttl-seconds: 21600\") && export DD_AGENT_HOST=$(curl -H \"X-aws-ec2-metadata-token: $TOKEN\" http://169.254.169.254/latest/meta-data/local-ipv4) && java -javaagent:dd-java-agent.jar -Ddd.profiling.enabled=true -XX:FlightRecorderOptions=stackdepth=256 -Ddd.appsec.enabled=true -Ddd.iast.enabled=true -Ddd.logs.injection=true -Ddd.jmxfetch.enabled=true -Ddd.service=gloddy-community -Ddd.env=staging -jar app.jar"]
ENTRYPOINT ["java", "-javaagent:dd-java-agent.jar", "-Ddd.profiling.enabled=true", "-XX:FlightRecorderOptions=stackdepth=256", "-Ddd.appsec.enabled=true", "-Ddd.iast.enabled=true", "-Ddd.logs.injection=true", "-Ddd.jmxfetch.enabled=true", "-Ddd.service=gloddy-community", "-Ddd.env=staging", "-jar", "app.jar"]
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package gloddy.article.port.`in`

import gloddy.article.port.`in`.dto.command.ArticleCreateRequest
import gloddy.article.port.`in`.dto.command.ArticleUpsertCommentRequest
import gloddy.article.port.`in`.dto.read.ArticleCreateResponse

interface ArticleCommandUseCase {
fun create(userId: Long, command: ArticleCreateRequest): ArticleCreateResponse
fun delete(userId: Long, articleId: Long)
fun upsertLike(userId: Long, articleId: Long)
fun upsertComment(request: ArticleUpsertCommentRequest)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package gloddy.article.port.`in`.dto.command

data class ArticleUpsertCommentRequest(
val articleId: Long,
val status: CommentStatus
)

enum class CommentStatus {
CREATE, DELETE
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import gloddy.article.ArticleLike
import gloddy.article.port.`in`.dto.command.ArticleCreateRequest
import gloddy.article.port.`in`.dto.read.ArticleCreateResponse
import gloddy.article.port.`in`.ArticleCommandUseCase
import gloddy.article.port.`in`.dto.command.ArticleUpsertCommentRequest
import gloddy.article.port.`in`.dto.command.CommentStatus
import gloddy.article.port.out.ArticleCommandPersistencePort
import gloddy.article.port.out.ArticleLikeCommandPersistencePort
import gloddy.article.port.out.ArticleLikeQueryPersistencePort
Expand All @@ -19,7 +21,6 @@ class ArticleCommandService(
private val categoryQueryPersistencePort: CategoryQueryPersistencePort,
private val articleQueryPersistencePort: ArticleQueryPersistencePort,
private val articleCommandPersistencePort: ArticleCommandPersistencePort,
private val articleLikeCommandPersistencePort: ArticleLikeCommandPersistencePort,
private val articleLikeQueryPersistencePort: ArticleLikeQueryPersistencePort,
) : ArticleCommandUseCase {

Expand Down Expand Up @@ -60,4 +61,12 @@ class ArticleCommandService(
article = article.like()
)
}

override fun upsertComment(request: ArticleUpsertCommentRequest) {
val article = articleQueryPersistencePort.findById(request.articleId)
when(request.status) {
CommentStatus.CREATE -> articleCommandPersistencePort.save(article.comment())
CommentStatus.DELETE -> articleCommandPersistencePort.save(article.unComment())
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class ArticleQueryService(
id = request.id,
userId = request.userId
)
val userPreviewUnit = userQueryPort.getUserPreviewUnit(request.userId)
val userPreviewUnit = userQueryPort.getUserPreviewUnit(articleDetailUnit.userId)
return ArticleDetailResponse(
article = articleDetailUnit,
writer = userPreviewUnit
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package gloddy.comment.dto

data class ChildCommentGetRequest(
val parentId: Long,
val userId: Long
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package gloddy.comment.dto

import gloddy.article.port.`in`.dto.command.CommentStatus
import gloddy.core.CommentId

data class CommentChildUpsertRequest(
val commentId: CommentId,
val status: CommentStatus
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package gloddy.comment.dto

import gloddy.core.ArticleId
import gloddy.core.CommentId
import gloddy.core.UserId

data class ParentCommentCreateRequest(
val userId: UserId,
val articleId: ArticleId,
val content: String
)

data class ChildCommentCreateRequest(
val userId: UserId,
val articleId: ArticleId,
val parentCommentId: CommentId,
val content: String
)

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package gloddy.comment.dto

import gloddy.comment.Comment

data class CommentCreateResponse(
val commentId: Long
) {
constructor(comment: Comment) : this(
commentId = comment.id!!.value
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package gloddy.comment.dto

import gloddy.core.ArticleId
import gloddy.core.CommentId
import gloddy.core.UserId

data class CommentDeleteRequest(
val commentId: CommentId,
val userId: UserId,
val articleId: ArticleId
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package gloddy.comment.dto

import gloddy.comment.Comment

data class CommentGetResponse(
val comments: List<CommentUnit>
)

data class CommentUnit(
val commentId: Long,
val content: String,
val depth: Int,
val likeCount: Long,
val commentCount: Long,
val isLiked: Boolean,
val user: UserUnit
)

data class UserUnit(
val userId: Long,
val name: String,
val imageUrl: String,
val reliabilityLevel: String,
val country: UserCountry
)

data class UserCountry(
val name: String,
val imageUrl: String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package gloddy.comment.dto

import gloddy.core.CommentId
import gloddy.core.UserId

data class CommentLikeUpsertRequest(
val userId: UserId,
val commentId: CommentId
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package gloddy.comment.dto

import gloddy.core.ArticleId
import gloddy.core.UserId

data class ParentCommentGetRequest(
val userId: UserId,
val articleId: ArticleId
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package gloddy.comment.dto.readModel

import java.time.LocalDateTime

data class ChildCommentUnit(
val id: Long,
val isWriter: Boolean,
val isLiked: Boolean,
val userId: Long,
val articleId: Long,
val parentId: Long,
val content: String,
val likeCount: Int,
val createdAt: LocalDateTime,
val updatedAt: LocalDateTime
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package gloddy.comment.dto.readModel

import gloddy.user.port.`in`.dto.UserPreviewUnit

data class FindChildCommentByParentIdResponse(
val childComment: ChildCommentUnit,
val writer: UserPreviewUnit
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package gloddy.comment.dto.readModel

data class FindChildCommentsByParentIdResponse(
val childComments: List<FindChildCommentByParentIdResponse>
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package gloddy.comment.dto.readModel

import gloddy.user.port.`in`.dto.UserPreviewUnit

data class FindParentCommentByArticleIdResponse(
val comment: ParentCommentUnit,
val writer: UserPreviewUnit
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package gloddy.comment.dto.readModel

data class FindParentCommentsByArticleIdResponse(
val comments: List<FindParentCommentByArticleIdResponse>
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package gloddy.comment.dto.readModel

import java.time.LocalDateTime

data class ParentCommentUnit(
val id: Long,
val isWriter: Boolean,
val isLiked: Boolean,
val userId: Long,
val articleId: Long,
val content: String,
val likeCount: Int,
val commentCount: Int,
val createdAt: LocalDateTime,
val updatedAt: LocalDateTime,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package gloddy.comment.port.out

import gloddy.comment.Comment
import gloddy.comment.CommentLike

interface CommentCommandPort {
fun save(comment: Comment): Comment
fun delete(comment: Comment)
fun upsertLike(commentLike: CommentLike, comment: Comment)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package gloddy.comment.port.out

import gloddy.comment.CommentLike

interface CommentLikeCommandPort {
fun save(commentLike: CommentLike): CommentLike
fun delete(commentLike: CommentLike)
}
Loading
Loading