Skip to content

Commit 1d64d87

Browse files
authored
Merge pull request #120 from CommitField/dev
fix: ๋ ˆ๋””์Šค ๊ถŒํ•œ์˜ค๋ฅ˜ ํ•ด๊ฒฐ
2 parents eb4706e + c2cf9ca commit 1d64d87

File tree

8 files changed

+87
-38
lines changed

8 files changed

+87
-38
lines changed

โ€Ž.github/workflows/deploy.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ jobs:
2121
id: create_tag
2222
uses: mathieudutour/[email protected]
2323
with:
24-
github_token: ${{ secrets.GITHUB_TOKEN }}
24+
github_token: ${{ secrets.TOKEN_GITHUB }}
2525
- name: Create Release
2626
id: create_release
2727
uses: actions/create-release@v1
2828
env:
29-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29+
GITHUB_TOKEN: ${{ secrets.TOKEN_GITHUB }}
3030
with:
3131
tag_name: ${{ steps.create_tag.outputs.new_tag }}
3232
release_name: Release ${{ steps.create_tag.outputs.new_tag }}
@@ -46,7 +46,7 @@ jobs:
4646
with:
4747
registry: ghcr.io
4848
username: ${{ github.actor }}
49-
password: ${{ secrets.GITHUB_TOKEN }}
49+
password: ${{ secrets.TOKEN_GITHUB }}
5050
- name: set lower case owner name
5151
run: |
5252
echo "OWNER_LC=${OWNER,,}" >> ${GITHUB_ENV}

โ€Žsrc/main/java/cmf/commitField/domain/chat/chatRoom/controller/ChatRoomController.java

+33-6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import cmf.commitField.domain.chat.chatRoom.dto.ChatRoomUserDto;
88
import cmf.commitField.domain.chat.chatRoom.service.ChatRoomService;
99
import cmf.commitField.domain.user.entity.CustomOAuth2User;
10+
import cmf.commitField.global.aws.s3.S3Service;
1011
import cmf.commitField.global.error.ErrorCode;
1112
import cmf.commitField.global.globalDto.GlobalResponse;
1213
import cmf.commitField.global.security.LoginCheck;
@@ -28,25 +29,25 @@
2829
@RequestMapping("/chat")
2930
public class ChatRoomController {
3031
private final ChatRoomService chatRoomService;
31-
private final FileService fileService;
32+
private final S3Service s3Service; // S3 ํŒŒ์ผ ์ €์žฅ์„ ์œ„ํ•œ ์„œ๋น„์Šค
33+
private final FileService fileService; //local file ์ €์žฅ์„ ์œ„ํ•œ ์„œ๋น„์Šค
3234

3335
// ์ฑ„ํŒ…๋ฐฉ ์ƒ์„ฑ (ํŒŒ์ผ ์—…๋กœ๋“œ ํฌํ•จ)
3436
@PostMapping(value = "/room", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
3537
public GlobalResponse<Object> createRoom(
3638
@ModelAttribute @Valid ChatRoomRequest chatRoomRequest) throws IOException {
3739

38-
3940
// ์ธ์ฆ ํ™•์ธ
4041
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
4142

4243
if (authentication instanceof OAuth2AuthenticationToken) {
4344
CustomOAuth2User principal = (CustomOAuth2User) authentication.getPrincipal();
44-
Long userId = principal.getId(); // getId()๋ฅผ ํ†ตํ•ด userId๋ฅผ ์ถ”์ถœ
45+
Long userId = principal.getId(); // getId()๋ฅผ ํ†ตํ•ด userId ์ถ”์ถœ
4546

4647
// ํŒŒ์ผ ์—…๋กœ๋“œ ์ฒ˜๋ฆฌ
4748
String imageUrl = null;
4849
if (chatRoomRequest.getFile() != null && !chatRoomRequest.getFile().isEmpty()) {
49-
imageUrl = fileService.saveFile(chatRoomRequest.getFile()); // ํŒŒ์ผ ์ €์žฅ
50+
imageUrl = s3Service.uploadFile(chatRoomRequest.getFile(), "chat-room"); // S3์— ์—…๋กœ๋“œ
5051
}
5152

5253
// ์ฑ„ํŒ…๋ฐฉ ์ƒ์„ฑ ์„œ๋น„์Šค ํ˜ธ์ถœ (์ด๋ฏธ์ง€ URL ํฌํ•จ)
@@ -58,6 +59,7 @@ public GlobalResponse<Object> createRoom(
5859
}
5960
}
6061

62+
6163
//์ฑ„ํŒ…๋ฐฉ ์ž…์žฅ
6264
@PostMapping("/room/join/{roomId}")
6365
public GlobalResponse<Object> joinRoom(@PathVariable Long roomId, @RequestBody ChatRoomRequest chatRoomRequest) {
@@ -253,8 +255,33 @@ public GlobalResponse<Object> searchRoomName(
253255
}
254256
}
255257

256-
257-
258+
// // ์ฑ„ํŒ…๋ฐฉ ์ƒ์„ฑ (ํŒŒ์ผ ์—…๋กœ๋“œ ํฌํ•จ)
259+
// @PostMapping(value = "/room", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
260+
// public GlobalResponse<Object> createRoom(
261+
// @ModelAttribute @Valid ChatRoomRequest chatRoomRequest) throws IOException {
262+
//
263+
//
264+
// // ์ธ์ฆ ํ™•์ธ
265+
// Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
266+
//
267+
// if (authentication instanceof OAuth2AuthenticationToken) {
268+
// CustomOAuth2User principal = (CustomOAuth2User) authentication.getPrincipal();
269+
// Long userId = principal.getId(); // getId()๋ฅผ ํ†ตํ•ด userId๋ฅผ ์ถ”์ถœ
270+
//
271+
// // ํŒŒ์ผ ์—…๋กœ๋“œ ์ฒ˜๋ฆฌ
272+
// String imageUrl = null;
273+
// if (chatRoomRequest.getFile() != null && !chatRoomRequest.getFile().isEmpty()) {
274+
// imageUrl = fileService.saveFile(chatRoomRequest.getFile()); // ํŒŒ์ผ ์ €์žฅ
275+
// }
276+
//
277+
// // ์ฑ„ํŒ…๋ฐฉ ์ƒ์„ฑ ์„œ๋น„์Šค ํ˜ธ์ถœ (์ด๋ฏธ์ง€ URL ํฌํ•จ)
278+
// chatRoomService.createRoom(chatRoomRequest, userId, imageUrl);
279+
//
280+
// return GlobalResponse.success("์ฑ„ํŒ…๋ฐฉ์„ ์ƒ์„ฑํ•˜์˜€์Šต๋‹ˆ๋‹ค.");
281+
// } else {
282+
// throw new IllegalArgumentException("๋กœ๊ทธ์ธ ํ›„์— ์ด์šฉํ•ด ์ฃผ์„ธ์š”.");
283+
// }
284+
// }
258285

259286

260287
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//package cmf.commitField.domain.chat.chatRoom.controller.response;
2-
//
3-
//public class ChatRoomResponse {
4-
//}
1+
package cmf.commitField.domain.chat.chatRoom.controller.response;
2+
3+
public class ChatRoomResponse {
4+
}
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
package cmf.commitField.global.aws.s3;
22

3-
import jakarta.annotation.PreDestroy;
43
import org.springframework.stereotype.Component;
54
import software.amazon.awssdk.services.s3.S3Client;
6-
import software.amazon.awssdk.services.s3.model.ListObjectsV2Request;
7-
import software.amazon.awssdk.services.s3.model.ListObjectsV2Response;
8-
import software.amazon.awssdk.services.s3.model.S3Object;
95

106
@Component
117
public class S3Cleaner {
@@ -17,21 +13,21 @@ public S3Cleaner(S3Client s3Client) {
1713
this.s3Client = s3Client;
1814
}
1915

20-
@PreDestroy
21-
public void cleanup() {
22-
// S3์—์„œ ํ…Œ์ŠคํŠธ ํŒŒ์ผ ์‚ญ์ œ
23-
ListObjectsV2Request listObjects = ListObjectsV2Request.builder()
24-
.bucket(bucketName)
25-
.build();
26-
27-
// ํŒŒ์ผ ๋ชฉ๋ก์„ ๊ฐ€์ ธ์˜ต๋‹ˆ๋‹ค.
28-
ListObjectsV2Response listObjectsResponse = s3Client.listObjectsV2(listObjects);
29-
30-
// ๊ฐ ํŒŒ์ผ์„ ์‚ญ์ œํ•ฉ๋‹ˆ๋‹ค.
31-
for (S3Object s3Object : listObjectsResponse.contents()) {
32-
s3Client.deleteObject(builder -> builder.bucket(bucketName).key(s3Object.key()));
33-
}
34-
35-
System.out.println("S3์— ์žˆ๋Š” ํ…Œ์ŠคํŠธ ํŒŒ์ผ๋“ค์„ ์‚ญ์ œํ–ˆ์Šต๋‹ˆ๋‹ค.");
36-
}
16+
// @PreDestroy
17+
// public void cleanup() {
18+
// // S3์—์„œ ํ…Œ์ŠคํŠธ ํŒŒ์ผ ์‚ญ์ œ
19+
// ListObjectsV2Request listObjects = ListObjectsV2Request.builder()
20+
// .bucket(bucketName)
21+
// .build();
22+
//
23+
// // ํŒŒ์ผ ๋ชฉ๋ก์„ ๊ฐ€์ ธ์˜ต๋‹ˆ๋‹ค.
24+
// ListObjectsV2Response listObjectsResponse = s3Client.listObjectsV2(listObjects);
25+
//
26+
// // ๊ฐ ํŒŒ์ผ์„ ์‚ญ์ œํ•ฉ๋‹ˆ๋‹ค.
27+
// for (S3Object s3Object : listObjectsResponse.contents()) {
28+
// s3Client.deleteObject(builder -> builder.bucket(bucketName).key(s3Object.key()));
29+
// }
30+
//
31+
// System.out.println("S3์— ์žˆ๋Š” ํ…Œ์ŠคํŠธ ํŒŒ์ผ๋“ค์„ ์‚ญ์ œํ–ˆ์Šต๋‹ˆ๋‹ค.");
32+
// }
3733
}

โ€Žsrc/main/java/cmf/commitField/global/aws/s3/S3Service.java

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public String uploadFile(MultipartFile file, String dirName) throws IOException
2525
.bucket(BUCKET_NAME)
2626
.key(fileName)
2727
.contentType(file.getContentType())
28+
// .acl(ObjectCannedACL.PUBLIC_READ) // Public Read ๊ถŒํ•œ ์ถ”๊ฐ€
2829
.build();
2930

3031
s3Client.putObject(putObjectRequest,

โ€Žsrc/main/java/cmf/commitField/global/config/RedisConfig.java

+16
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package cmf.commitField.global.config;
22

3+
import org.redisson.Redisson;
4+
import org.redisson.config.Config;
5+
import org.redisson.api.RedissonClient;
36
import org.springframework.beans.factory.annotation.Value;
47
import org.springframework.context.annotation.Bean;
58
import org.springframework.context.annotation.Configuration;
@@ -19,6 +22,18 @@ public class RedisConfig {
1922
@Value("${spring.redis.port}")
2023
public int port;
2124

25+
@Value("${spring.redis.password}")
26+
public String password;
27+
28+
@Bean
29+
public RedissonClient redissonClient() {
30+
Config config = new Config();
31+
config.useSingleServer()
32+
.setAddress("redis://127.0.0.1:6379")
33+
.setPassword(password); // ๋น„๋ฐ€๋ฒˆํ˜ธ ์ถ”๊ฐ€
34+
return Redisson.create(config);
35+
}
36+
2237
@Bean
2338
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory connectionFactory) {
2439
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
@@ -33,6 +48,7 @@ public RedisConnectionFactory redisConnectionFactory() {
3348
RedisStandaloneConfiguration configuration = new RedisStandaloneConfiguration();
3449
configuration.setHostName(host);
3550
configuration.setPort(port);
51+
configuration.setPassword(password); // ๋น„๋ฐ€๋ฒˆํ˜ธ ์„ค์ •
3652
return new LettuceConnectionFactory(configuration);
3753
}
3854

โ€Žsrc/main/resources/application-prod.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ spring:
1616
redis:
1717
host: 172.17.0.1
1818
port: 6379
19-
password: ${custom.secret.spring.data.redis.password}
19+
password: ${spring.redis.password}
2020
jpa:
2121
hibernate:
2222
ddl-auto: update

โ€Žsrc/main/resources/application.yml

+12-3
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,25 @@ spring:
3333
frontUrl: "http://${custom.dev.cookieDomain}:5173"
3434
backUrl: "http://${custom.dev.cookieDomain}:${server.port}"
3535
prod:
36-
cookieDomain: cmfd.seoez.site
36+
cookieDomain: cmf.seoez.site
3737
frontUrl: "https://www.${custom.prod.cookieDomain}/"
3838
backUrl: "https://api.${custom.prod.cookieDomain}/"
3939
site:
4040
name: "commit-field"
4141
cookieDomain: "${custom.dev.cookieDomain}"
4242
frontUrl: "${custom.dev.frontUrl}"
4343
backUrl: "${custom.dev.backUrl}"
44+
# Lettuce ํด๋ผ์ด์–ธํŠธ ์„ค์ • (Redis ์—ฐ๊ฒฐ์„ ๊ด€๋ฆฌํ•˜๋Š” ํด๋ผ์ด์–ธํŠธ)
45+
redis:
46+
host: localhost # Redis ์„œ๋ฒ„์˜ ํ˜ธ์ŠคํŠธ๋ช… (Docker๋ฅผ ์‚ฌ์šฉํ•  ๊ฒฝ์šฐ `localhost` ๋˜๋Š” `host.docker.internal` ์‚ฌ์šฉ)
47+
port: 6379 # Redis ์„œ๋ฒ„ ํฌํŠธ
48+
49+
lettuce:
50+
pool:
51+
max-active: 10 # ์ตœ๋Œ€ ํ™œ์„ฑ ์ปค๋„ฅ์…˜ ์ˆ˜
52+
max-wait: -1 # ์ปค๋„ฅ์…˜ ํ’€์—์„œ ๋Œ€๊ธฐํ•  ์ˆ˜ ์žˆ๋Š” ์ตœ๋Œ€ ์‹œ๊ฐ„ (-1์€ ๋ฌด์ œํ•œ ๋Œ€๊ธฐ)
53+
max-idle: 8 # ์ปค๋„ฅ์…˜ ํ’€์—์„œ์˜ ์ตœ๋Œ€ ์œ ํœด ์ปค๋„ฅ์…˜ ์ˆ˜
54+
min-idle: 4 # ์ปค๋„ฅ์…˜ ํ’€์—์„œ์˜ ์ตœ์†Œ ์œ ํœด ์ปค๋„ฅ์…˜ ์ˆ˜
4455

4556
# swagger ์„ค์ •
4657
springdoc:
@@ -53,8 +64,6 @@ springdoc:
5364
# paths-to-match:
5465
# - /api/** # swagger-ui์— ํ‘œ์‹œํ•  api์˜ ์—”๋“œํฌ์ธํŠธ ํŒจํ„ด
5566

56-
kafka:
57-
bootstrap-servers: localhost:9092
5867

5968
logging:
6069
level:

0 commit comments

Comments
ย (0)