Skip to content

Commit 783d065

Browse files
authored
Merge pull request #454 from hyanyul/part4-한성지-sprint9
[한성지] sprint9
2 parents 4d88415 + ba20927 commit 783d065

File tree

154 files changed

+2485
-16875
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

154 files changed

+2485
-16875
lines changed

.gitignore

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ build/
1717
out/
1818
!**/src/main/**/out/
1919
!**/src/test/**/out/
20-
node_modules/
2120

2221
### Eclipse ###
2322
.apt_generated
@@ -48,5 +47,18 @@ bin/
4847
### data ###
4948
/data/
5049

50+
### Discodeit ###
51+
.discodeit
52+
5153
### env ###
52-
*.env
54+
*.env
55+
56+
### 숨김 파일 ###
57+
.*
58+
!.gitignore
59+
60+
### Github Actions ###
61+
!.github/
62+
63+
### log ###
64+
/logs/

Dockerfile

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,39 @@
1-
# 베이스 이미지 지정
2-
FROM amazoncorretto:17
1+
# 빌드 스테이지
2+
FROM amazoncorretto:17 AS builder
33

44
# 작업 디렉토리 설정
55
WORKDIR /app
66

7-
# 현재 디렉토리의 파일(프로젝트)을 복사
8-
COPY . .
7+
# Gradle Wrapper 파일 먼저 복사
8+
COPY gradle ./grale
9+
COPY gradlew ./gradlew
910

10-
# wait-for-it.sh 복사
11-
COPY wait-for-it.sh /app/wait-for-it.sh
12-
RUN chmod +x /app/wait-for-it.sh
11+
# Gradle 캐시를 위한 의존성 파일 복사
12+
COPY build.gradle setting.gradle ./
1313

14-
# Gradle Wrapper로 애플리케이션 빌드
15-
# 테스트 제외하고 빌드
14+
# 의존성 다운로드
15+
RUN ./gradlew dependencies
16+
17+
# 소스 코드 복사 및 빌드
18+
COPY src ./src
1619
RUN ./gradlew build -x test
1720

18-
# 80 포트 노출
19-
EXPOSE 80
21+
# 런타임 스테이지
22+
FROM amazoncorretto:17-alpine3.21
2023

21-
# 프로젝트 정보를 환경 변수로 설정
22-
ENV PROJECT_NAME="discodeit" PROJECT_VERSION="1.2-M8"
24+
# 작업 디렉토리 설정
25+
WORKDIR /app
2326

24-
# JVM 옵션을 환경 변수로 설정
25-
ENV JVM_OPTS=""
27+
# 프로젝트 정보를 ENV로 설정
28+
ENV PROJECT_NAME=discodeit \
29+
PROJECT_VERSION=1.2-MB \
30+
JVM_OPTS=""
31+
32+
# 빌드 스테이지에서 jar 파일만 복사
33+
COPY --from=builder /app/build/libs/${PROJECT_NAME}-${PROJECT_VERSION}.jar ./
34+
35+
# 80 포트 노출
36+
EXPOSE 80
2637

27-
# 애플리케이션 실행 명령어 설정
28-
# sh, -c : 리눅스 쉘 명령어에서 문자열 전체를 하나의 명령어처럼 실행하라
29-
# 환경변수를 문자열 안에서 해석해주기 위해 필요
30-
CMD ["sh", "-c", "./wait-for-it.sh postgres:5432 -- java $JVM_OPTS -jar build/libs/${PROJECT_NAME}-${PROJECT_VERSION}.jar"]
38+
# jar 파일 실행
39+
ENTRYPOINT ["sh", "-c", "java ${JVM_OPTS} -jar ${PROJECT_NAME}-${PROJECT_VERSION}.jar"]

build.gradle

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,11 @@ plugins {
22
id 'java'
33
id 'org.springframework.boot' version '3.4.0'
44
id 'io.spring.dependency-management' version '1.1.7'
5+
id 'jacoco'
56
}
67

78
group = 'com.sprint.mission'
8-
version = '1.2-M8'
9-
10-
bootJar {
11-
archiveFileName = "discodeit-${version}.jar"
12-
}
9+
version = '0.0.1-SNAPSHOT'
1310

1411
java {
1512
toolchain {
@@ -21,6 +18,9 @@ configurations {
2118
compileOnly {
2219
extendsFrom annotationProcessor
2320
}
21+
testComplieOnly {
22+
extendsFrom testAnnotationProcessor
23+
}
2424
}
2525

2626
repositories {
@@ -31,8 +31,9 @@ dependencies {
3131
implementation 'org.springframework.boot:spring-boot-starter-web'
3232
compileOnly 'org.projectlombok:lombok'
3333
annotationProcessor 'org.projectlombok:lombok'
34-
testImplementation 'org.springframework.boot:spring-boot-starter-test'
35-
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
34+
35+
// security
36+
implementation 'org.springframework.boot:spring-boot-starter-security'
3637

3738
// validation
3839
implementation 'org.springframework.boot:spring-boot-starter-validation'
@@ -51,10 +52,25 @@ dependencies {
5152
// actuator
5253
implementation 'org.springframework.boot:spring-boot-starter-actuator'
5354

54-
// aws s3 sdk
55-
implementation 'software.amazon.awssdk:s3:2.31.7'
55+
// test
56+
testImplementation 'org.springframework.boot:spring-boot-starter-test'
57+
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
58+
testImplementation 'com.h2database:h2:2.2.224'
59+
testImplementation 'org.springframework.security:spring-security-test'
5660
}
5761

5862
tasks.named('test') {
5963
useJUnitPlatform()
6064
}
65+
66+
test {
67+
finalizedBy jacocoTestReport
68+
}
69+
70+
jacocoTestReport {
71+
dependsOn test
72+
reports {
73+
xml.required = true
74+
html.required = true
75+
}
76+
}

docker-compose.yaml

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,52 @@
1+
version: '3.8'
2+
13
services:
24
app:
5+
image: discodeit:local
36
build:
47
context: .
58
dockerfile: Dockerfile
9+
container_name: discodeit
610
ports:
7-
- "8080:80"
11+
- "8081:80"
812
environment:
9-
- SPRING_DATASOURCE_URL=${SPRING_DATASOURCE_URL}
10-
- SPRING_DATASOURCE_USERNAME=${POSTGRES_USER}
11-
- SPRING_DATASOURCE_PASSWORD=${POSTGRES_PASSWORD}
13+
- SPRING_PROFILES_ACTIVE=prod
14+
- SPRING_DATASOURCE_URL=jdbc:postgresql://db:5432/discodeit
15+
- SPRING_DATASOURCE_USERNAME=${SPRING_DATASOURCE_USERNAME}
16+
- SPRING_DATASOURCE_PASSWORD=${SPRING_DATASOURCE_PASSWORD}
17+
- STORAGE_TYPE=s3
18+
- STORAGE_LOCAL_ROOT_PATH=.discodeit/storage
1219
- AWS_S3_ACCESS_KEY=${AWS_S3_ACCESS_KEY}
1320
- AWS_S3_SECRET_KEY=${AWS_S3_SECRET_KEY}
1421
- AWS_S3_REGION=${AWS_S3_REGION}
1522
- AWS_S3_BUCKET=${AWS_S3_BUCKET}
16-
volumes: # BinaryCotentStorage를 로컬 폴더와 연결
17-
- ./BinaryContentStorage:/app/BinaryContentStorage
23+
- AWS_S3_PRESIGNED_URL=EXPIRATION=600
1824
depends_on:
19-
- postgres
20-
command: >
21-
sh -c '/app/wait-for-it.sh postgres:5432 --timeout=60 -- java $JVM_OPTS -jar build/libs/${PROJECT_NAME}-${PROJECT_VERSION}.jar'
25+
- db
26+
volumes:
27+
- binary-content-storage:/app/.discodeit/storage
28+
networks:
29+
- discodeit-network
2230

23-
postgres:
24-
image: postgres:15
25-
ports:
26-
- "5432:5432"
31+
db:
32+
image: postgres:16-alpine
33+
container_name: discodeit-db
2734
environment:
35+
- POSTGRES_DB=discodeit
2836
- POSTGRES_USER=${POSTGRES_USER}
2937
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
30-
- POSTGRES_DB=${POSTGRES_DB}
38+
ports:
39+
- "5432:5432"
3140
volumes:
3241
- postgres-data:/var/lib/postgresql/data
33-
- ./schema.sql:/docker-entrypoint-initdb.d/schema.sql # postgreSQL 실행 시 자동 실행
42+
- ./src/main/resources/schema.sql:/docker-entrypoint-initdb.d/schema.sql
43+
networks:
44+
- discodeit-network
3445

3546
volumes:
36-
postgres-data:
47+
postgres-data:
48+
binary-content-storage:
49+
50+
networks:
51+
discodeit-network:
52+
driver: bridge

frontend/.gitignore

Lines changed: 0 additions & 24 deletions
This file was deleted.

frontend/README.md

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)