Skip to content

Commit fcbf246

Browse files
authored
Merge branch 'dev' into Test/202
2 parents 0f89a4b + 08acaf3 commit fcbf246

34 files changed

+2210
-156
lines changed

.github/workflows/backend-cd.yml

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
runs-on: ubuntu-latest
4242
env:
4343
DOCKER_IMAGE_NAME: catfe-backend
44-
DOT_ENV: ${{ secrets.DOT_ENV }}
44+
DOT_ENV: ${{ secrets.DOT_ENV_PROD }}
4545
OWNER: ${{ github.repository_owner }}
4646
steps:
4747
- uses: actions/checkout@v4
@@ -77,7 +77,7 @@ jobs:
7777
runs-on: ubuntu-latest
7878
needs: [ makeTagAndRelease, buildImageAndPush ]
7979
env:
80-
IMAGE_REPOSITORY: catfe_backend # 도커 이미지 명
80+
IMAGE_REPOSITORY: catfe-backend # 도커 이미지 명
8181
CONTAINER_1_NAME: catfe_1 # 슬롯 1
8282
CONTAINER_2_NAME: catfe_2 # 슬롯 2
8383
CONTAINER_PORT: 8080 # 컨테이너 내부 포트
@@ -112,9 +112,6 @@ jobs:
112112
command: |
113113
set -Eeuo pipefail
114114
115-
# 1. EC2 인스턴스 아이디 확인
116-
echo "INSTANCE_ID=${INSTANCE_ID}"
117-
118115
# 3. 실행 로그(라인 타임스탬프 부착)
119116
LOG="/tmp/ssm-$(date +%Y%m%d_%H%M%S).log"
120117
exec > >(awk '{ fflush(); print strftime("[%Y-%m-%d %H:%M:%S]"), $0 }' | tee -a "$LOG")
@@ -140,18 +137,18 @@ jobs:
140137
TOKEN=$(curl -s -X POST http://127.0.0.1:81/api/tokens \
141138
-H "Content-Type: application/json" \
142139
-d "{\"identity\": \"[email protected]\", \"secret\": \"${PASSWORD:-}\"}" | jq -r '.token')
143-
140+
144141
# 조회한 토큰과 도메인 검증
145142
[[ -n "${TOKEN}" && "${TOKEN}" != "null" ]] || { echo "NPM token issue failed"; exit 1; }
146143
[[ -n "${DOMAIN:-}" ]] || { echo "DOMAIN is empty"; exit 1; }
147144
148145
# 6. 대상 프록시 호스트 ID 조회(도메인 매칭)
149146
PROXY_ID=$(curl -s -X GET "http://127.0.0.1:81/api/nginx/proxy-hosts" \
150147
-H "Authorization: Bearer ${TOKEN}" \
151-
| jq ".[] | select(.domain_names[]==\"${APP_1_DOMAIN}\") | .id")
152-
148+
| jq ".[] | select(.domain_names[]==\"${DOMAIN}\") | .id")
149+
153150
# 조회한 프록시 호스트 ID 검증
154-
[[ -n "${PROXY_ID}" && "${PROXY_ID}" != "null" ]] || { echo "Proxy host not found for ${APP_1_DOMAIN}"; exit 1; }
151+
[[ -n "${PROXY_ID}" && "${PROXY_ID}" != "null" ]] || { echo "Proxy host not found for ${DOMAIN}"; exit 1; }
155152
156153
# 현재 프록시가 바라보는 업스트림(컨테이너명) 조회
157154
CURRENT_HOST=$(curl -s -X GET "http://127.0.0.1:81/api/nginx/proxy-hosts/${PROXY_ID}" \
@@ -179,9 +176,9 @@ jobs:
179176
echo "🎨 role -> blue(now): ${BLUE}, green(next): ${GREEN}"
180177
181178
# 8. Green 역할 컨테이너
182-
docker rm -f "${Green}" > /dev/null 2>&1 || true
183-
echo "run new container -> ${Green}"
184-
docker run -d --name "${Green}" \
179+
docker rm -f "${GREEN}" > /dev/null 2>&1 || true
180+
echo "run new container -> ${GREEN}"
181+
docker run -d --name "${GREEN}" \
185182
--restart unless-stopped \
186183
--network "${NET}" \
187184
-e TZ=Asia/Seoul \
@@ -234,4 +231,3 @@ jobs:
234231
235232
236233
237-

build.gradle.kts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ dependencies {
7474
// Redis
7575
implementation("org.springframework.boot:spring-boot-starter-data-redis")
7676
implementation("com.github.codemonstur:embedded-redis:1.4.3")
77+
78+
// AWS S3
79+
implementation ("org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE")
7780
}
7881

7982
tasks.withType<Test> {

infra/terraform/main.tf

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,8 @@ sudo sh -c 'echo "/swapfile swap swap defaults 0 0" >> /etc/fstab'
198198
echo "PASSWORD=${var.password_1}" >> /etc/environment
199199
echo "DOMAIN=${var.catfe_domain_1}" >> /etc/environment
200200
echo "GITHUB_ACCESS_TOKEN_OWNER=${var.github_access_token_1_owner}" >> /etc/environment
201-
ehco "GITHUB_ACCESS_TOKEN=${var.github_access_token_1}" >> /etc/environment
201+
echo "GITHUB_ACCESS_TOKEN=${var.github_access_token_1}" >> /etc/environment
202+
202203
# EC2 환경변수 등록
203204
source /etc/environment
204205
@@ -340,4 +341,30 @@ resource "aws_db_instance" "mysql" {
340341
Value = "devcos-team05"
341342
Name = "team5-mysql"
342343
}
344+
}
345+
346+
# EC2 역할에 AmazonS3FullAccess 정책을 부착
347+
resource "aws_iam_role_policy_attachment" "s3_full_access" {
348+
role = aws_iam_role.ec2_role_1.name
349+
policy_arn = "arn:aws:iam::aws:policy/AmazonS3FullAccess"
350+
}
351+
352+
# S3 접근 권한 추가
353+
resource "aws_s3_bucket_public_access_block" "public-access" {
354+
bucket = aws_s3_bucket.s3_1.id
355+
356+
block_public_acls = false
357+
block_public_policy = false
358+
ignore_public_acls = false
359+
restrict_public_buckets = false
360+
}
361+
362+
# S3 인스턴스 생성
363+
resource "aws_s3_bucket" "s3_1" {
364+
bucket = "team5-s3-1"
365+
tags = {
366+
Key = "TEAM"
367+
Value = "devcos-team05"
368+
Name = "team5-s3-1"
369+
}
343370
}

infra/terraform/variables.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
variable "catfe_domain_1" {
2-
description = "api.catfe.site"
2+
description = "domain_1"
3+
default = "api.catfe.site"
34
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package com.back.domain.board.comment.controller;
2+
3+
import com.back.domain.board.comment.dto.CommentLikeResponse;
4+
import com.back.domain.board.comment.service.CommentLikeService;
5+
import com.back.global.common.dto.RsData;
6+
import com.back.global.security.user.CustomUserDetails;
7+
import lombok.RequiredArgsConstructor;
8+
import org.springframework.http.ResponseEntity;
9+
import org.springframework.security.core.annotation.AuthenticationPrincipal;
10+
import org.springframework.web.bind.annotation.*;
11+
12+
@RestController
13+
@RequestMapping("/api/posts/{postId}/comments/{commentId}/like")
14+
@RequiredArgsConstructor
15+
public class CommentLikeController implements CommentLikeControllerDocs {
16+
private final CommentLikeService commentLikeService;
17+
18+
// 댓글 좋아요
19+
@PostMapping
20+
public ResponseEntity<RsData<CommentLikeResponse>> likeComment(
21+
@PathVariable Long postId,
22+
@PathVariable Long commentId,
23+
@AuthenticationPrincipal CustomUserDetails user
24+
) {
25+
CommentLikeResponse response = commentLikeService.likeComment(commentId, user.getUserId());
26+
return ResponseEntity
27+
.ok(RsData.success(
28+
"댓글 좋아요가 등록되었습니다.",
29+
response
30+
));
31+
}
32+
33+
// 댓글 좋아요 취소
34+
@DeleteMapping
35+
public ResponseEntity<RsData<CommentLikeResponse>> cancelLikeComment(
36+
@PathVariable Long postId,
37+
@PathVariable Long commentId,
38+
@AuthenticationPrincipal CustomUserDetails user
39+
) {
40+
CommentLikeResponse response = commentLikeService.cancelLikeComment(commentId, user.getUserId());
41+
return ResponseEntity
42+
.ok(RsData.success(
43+
"댓글 좋아요가 취소되었습니다.",
44+
response
45+
));
46+
}
47+
}

0 commit comments

Comments
 (0)