Skip to content

Commit 4ad4219

Browse files
committed
Merge remote-tracking branch 'origin/dev' into feat/96
2 parents 7c63896 + ef8cead commit 4ad4219

File tree

12 files changed

+258
-136
lines changed

12 files changed

+258
-136
lines changed

.github/workflows/backend-ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ jobs:
2424
distribution: 'temurin' # Eclipse Temurin JDK
2525
java-version: '21' # Gradle build.gradle toolchain에 맞춤
2626

27+
# .env 파일 생성
28+
- name: Create .env file
29+
run: echo "${{ secrets.DOT_ENV }}" > .env
30+
2731
# Build (테스트 제외)
2832
- name: Build project
2933
run: ./gradlew clean build -x test

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,5 @@ db_dev.trace.db
4646
/infra/terraform/.terraform
4747
/infra/terraform/.terraform.lock.hcl
4848
/infra/terraform/terraform.tfstate
49-
/infra/terraform/terraform.tfstate.backup
49+
/infra/terraform/terraform.tfstate.backup
50+
/infra/terraform/secrets.tf

build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ dependencies {
6464
// Test
6565
testImplementation("org.springframework.boot:spring-boot-starter-test")
6666
testImplementation("org.springframework.security:spring-security-test")
67+
testImplementation("org.testcontainers:testcontainers:1.19.3")
68+
testImplementation("org.testcontainers:junit-jupiter:1.19.3")
6769
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
6870

6971
// Redis

infra/terraform/main.tf

Lines changed: 90 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ resource "aws_vpc" "vpc_1" {
1919
enable_dns_hostnames = true
2020

2121
tags = {
22-
Name = "team5-vpc-1"
22+
Key = "TEAM"
23+
Value = "devcos-team05"
24+
Name = "team5-vpc-1"
2325
}
2426
}
2527

@@ -31,7 +33,9 @@ resource "aws_subnet" "subnet_1" {
3133
map_public_ip_on_launch = true # 퍼블릭 IP 자동 할당
3234

3335
tags = {
34-
Name = "team5-subnet-1-public"
36+
Key = "TEAM"
37+
Value = "devcos-team05"
38+
Name = "team5-subnet-1-public"
3539
}
3640
}
3741

@@ -42,7 +46,9 @@ resource "aws_subnet" "subnet_2" {
4246
availability_zone = "ap-northeast-2a"
4347

4448
tags = {
45-
Name = "team5-subnet-2-private"
49+
Key = "TEAM"
50+
Value = "devcos-team05"
51+
Name = "team5-subnet-2-private"
4652
}
4753
}
4854

@@ -53,7 +59,9 @@ resource "aws_subnet" "subnet_3" {
5359
availability_zone = "ap-northeast-2b"
5460

5561
tags = {
56-
Name = "team5-subnet-3-private"
62+
Key = "TEAM"
63+
Value = "devcos-team05"
64+
Name = "team5-subnet-3-private"
5765
}
5866
}
5967

@@ -62,7 +70,9 @@ resource "aws_internet_gateway" "igw_1" {
6270
vpc_id = aws_vpc.vpc_1.id
6371

6472
tags = {
65-
Name = "team5-igw-1"
73+
Key = "TEAM"
74+
Value = "devcos-team05"
75+
Name = "team5-igw-1"
6676
}
6777
}
6878

@@ -77,7 +87,9 @@ resource "aws_route_table" "rt_1" {
7787
}
7888

7989
tags = {
80-
Name = "team5-rt-1"
90+
Key = "TEAM"
91+
Value = "devcos-team05"
92+
Name = "team5-rt-1"
8193
}
8294
}
8395

@@ -104,8 +116,14 @@ resource "aws_route_table_association" "association_3" {
104116
}
105117

106118
resource "aws_security_group" "sg_1" {
107-
name = "team5-sg-1"
108-
vpc_id = aws_vpc.vpc_1.id
119+
name = "team5-sg-1"
120+
vpc_id = aws_vpc.vpc_1.id
121+
122+
tags = {
123+
Key = "TEAM"
124+
Value = "devcos-team05"
125+
Name = "team5-sg-1"
126+
}
109127

110128
ingress {
111129
from_port = 0
@@ -124,7 +142,11 @@ resource "aws_security_group" "sg_1" {
124142

125143
# EC2 역할 생성
126144
resource "aws_iam_role" "ec2_role_1" {
127-
name = "team5-ec2-role-1"
145+
tags = {
146+
Key = "TEAM"
147+
Value = "devcos-team05"
148+
Name = "team5-ec2-role-1"
149+
}
128150

129151
# 이 역할에 대한 신뢰 정책 설정. EC2 서비스가 이 역할을 가정할 수 있도록 설정
130152
assume_role_policy = <<EOF
@@ -152,26 +174,62 @@ resource "aws_iam_role_policy_attachment" "ec2_ssm" {
152174

153175
# IAM 인스턴스 프로파일 생성
154176
resource "aws_iam_instance_profile" "instance_profile_1" {
155-
name = "team5-instance-profile-1"
177+
tags = {
178+
Key = "TEAM"
179+
Value = "devcos-team05"
180+
Name = "team5-instance-profile-1"
181+
}
182+
156183
role = aws_iam_role.ec2_role_1.name
157184
}
158185

159186
# EC2 실행마다 적용할 작업
160187
locals {
161188
ec2_user_data_base = <<-END_OF_FILE
162189
#!/bin/bash
163-
yum install docker -y
164-
systemctl enable docker
165-
systemctl start docker
166-
167-
yum install git -y
168-
190+
# 가상 메모리 4GB 설정
169191
sudo dd if=/dev/zero of=/swapfile bs=128M count=32
170192
sudo chmod 600 /swapfile
171193
sudo mkswap /swapfile
172194
sudo swapon /swapfile
173195
sudo sh -c 'echo "/swapfile swap swap defaults 0 0" >> /etc/fstab'
174196
197+
# git 설치
198+
yum install git -y
199+
200+
#도커 설치 및 실행/활성화
201+
yum install docker -y
202+
systemctl enable docker
203+
systemctl start docker
204+
205+
# 도커 네트워크 생성
206+
docker network create common
207+
208+
# redis 설치
209+
docker run -d \
210+
--name redis_1 \
211+
--network common \
212+
-p 6379:6379 \
213+
-e TZ=Asia/Seoul \
214+
-v /dockerProjects/redis_1/volumes/data:/data \
215+
redis --requirepass ${var.password_1}
216+
217+
# NginX 설치
218+
docker run -d \
219+
--name npm_1 \
220+
--restart unless-stopped \
221+
--network common \
222+
-p 80:80 \
223+
-p 443:443 \
224+
-p 81:81 \
225+
-e TZ=Asia/Seoul \
226+
227+
-e INITIAL_ADMIN_PASSWORD=${var.password_1} \
228+
-v /dockerProjects/npm_1/volumes/data:/data \
229+
-v /dockerProjects/npm_1/volumes/etc/letsencrypt:/etc/letsencrypt \
230+
jc21/nginx-proxy-manager:latest
231+
232+
175233
END_OF_FILE
176234
}
177235

@@ -189,7 +247,9 @@ resource "aws_instance" "ec2_1" {
189247
iam_instance_profile = aws_iam_instance_profile.instance_profile_1.name
190248

191249
tags = {
192-
Name = "team5-ec2-1"
250+
Key = "TEAM"
251+
Value = "devcos-team05"
252+
Name = "team5-ec2-1"
193253
}
194254

195255
# 루트 불륨 설정
@@ -211,9 +271,9 @@ resource "aws_security_group" "rds_sg_1" {
211271
vpc_id = aws_vpc.vpc_1.id
212272

213273
ingress {
214-
from_port = 3306
215-
to_port = 3306
216-
protocol = "tcp"
274+
from_port = 3306
275+
to_port = 3306
276+
protocol = "tcp"
217277
cidr_blocks = ["0.0.0.0/0"]
218278
}
219279

@@ -225,7 +285,9 @@ resource "aws_security_group" "rds_sg_1" {
225285
}
226286

227287
tags = {
228-
Name = "team5-rds-sg-1"
288+
Key = "TEAM"
289+
Value = "devcos-team05"
290+
Name = "team5-rds-sg-1"
229291
}
230292
}
231293

@@ -235,7 +297,9 @@ resource "aws_db_subnet_group" "db_subnet_group" {
235297
subnet_ids = [aws_subnet.subnet_2.id, aws_subnet.subnet_3.id]
236298

237299
tags = {
238-
Name = "team5-db-subnet-group"
300+
Key = "TEAM"
301+
Value = "devcos-team05"
302+
Name = "team5-db-subnet-group"
239303
}
240304
}
241305

@@ -260,10 +324,12 @@ resource "aws_db_instance" "mysql" {
260324
# 자동 백업 보관 기간
261325
backup_retention_period = 1
262326

263-
# 삭제 시 최종 스냅샷 생성 여부 (개발용은 true, 운영은 false 권장)
327+
# 삭제 시 최종 스냅샷 생성 여부
264328
skip_final_snapshot = true
265329

266330
tags = {
267-
Name = "team5-rds-mysql"
331+
Key = "TEAM"
332+
Value = "devcos-team05"
333+
Name = "team5-mysql"
268334
}
269335
}

src/main/java/com/back/global/config/EmbeddedRedisConfig.java

Lines changed: 0 additions & 65 deletions
This file was deleted.
Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package com.back.global.config;
22

3+
import com.fasterxml.jackson.databind.ObjectMapper;
4+
import com.fasterxml.jackson.databind.SerializationFeature;
5+
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
36
import org.springframework.context.annotation.Bean;
47
import org.springframework.context.annotation.Configuration;
58
import org.springframework.data.redis.connection.RedisConnectionFactory;
@@ -13,24 +16,25 @@
1316
@Configuration
1417
public class RedisConfig {
1518

16-
/**
17-
* RedisTemplate 설정
18-
* - Key: String
19-
* - Value: JSON (Jackson)
20-
*/
2119
@Bean
2220
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory connectionFactory) {
2321
RedisTemplate<String, Object> template = new RedisTemplate<>();
2422
template.setConnectionFactory(connectionFactory);
2523

26-
// Key: String
24+
// ObjectMapper 설정
25+
ObjectMapper objectMapper = new ObjectMapper();
26+
objectMapper.registerModule(new JavaTimeModule());
27+
objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
28+
29+
// Jackson2JsonRedisSerializer 사용
30+
Jackson2JsonRedisSerializer<Object> serializer =
31+
new Jackson2JsonRedisSerializer<>(objectMapper, Object.class);
32+
2733
template.setKeySerializer(new StringRedisSerializer());
2834
template.setHashKeySerializer(new StringRedisSerializer());
29-
30-
// Value: JSON
31-
template.setValueSerializer(new Jackson2JsonRedisSerializer<>(Object.class));
32-
template.setHashValueSerializer(new Jackson2JsonRedisSerializer<>(Object.class));
35+
template.setValueSerializer(serializer);
36+
template.setHashValueSerializer(serializer);
3337

3438
return template;
3539
}
36-
}
40+
}

src/main/java/com/back/global/security/SecurityConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
3636
.authorizeHttpRequests(
3737
auth -> auth
3838
.requestMatchers("/api/auth/**", "/oauth2/**", "/login/oauth2/**").permitAll()
39-
.requestMatchers("/api/ws/**").permitAll()
39+
.requestMatchers("api/ws/**", "/ws/**").permitAll()
4040
.requestMatchers("/api/rooms/*/messages/**").permitAll() //스터디 룸 내에 잡혀있어 있는 채팅 관련 전체 허용
4141
//.requestMatchers("/api/rooms/RoomChatApiControllerTest").permitAll() // 테스트용 임시 허용
4242
.requestMatchers("/","/swagger-ui/**", "/v3/api-docs/**").permitAll() // Swagger 허용

0 commit comments

Comments
 (0)