Skip to content

Commit 6d39588

Browse files
authored
Merge pull request #2 from MuaProject/Setting/#1/init
[Setting] 프로젝트 초기 세팅
2 parents 5111830 + fe37e41 commit 6d39588

25 files changed

Lines changed: 681 additions & 6 deletions
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
name: Issue template
3+
about: Describe this issue purpose here.
4+
title: ""
5+
labels: ""
6+
assignees: ""
7+
---
8+
9+
## 목적
10+
11+
## 세부 내용 설명

‎.github/workflows/cd.yml‎

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: CD
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
7+
jobs:
8+
deploy:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v4
14+
15+
- name: Set up JDK 17
16+
uses: actions/setup-java@v4
17+
with:
18+
java-version: '17'
19+
distribution: 'temurin'
20+
21+
- name: Grant execute permission
22+
run: chmod +x ./gradlew
23+
24+
- name: Build
25+
run: ./gradlew clean build -x test
26+
27+
- name: Login Docker Hub
28+
uses: docker/login-action@v2
29+
with:
30+
username: ${{ secrets.DOCKERHUB_USERNAME }}
31+
password: ${{ secrets.DOCKERHUB_TOKEN }}
32+
33+
- name: Build & Push Image
34+
run: |
35+
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/mua-backend:${{ github.sha }} .
36+
docker push ${{ secrets.DOCKERHUB_USERNAME }}/mua-backend:${{ github.sha }}
37+
38+
- name: Deploy to WAS
39+
uses: appleboy/ssh-action@v0.1.6
40+
with:
41+
host: ${{ secrets.WAS_HOST }}
42+
username: ${{ secrets.WAS_USERNAME }}
43+
key: ${{ secrets.SSH_KEY }}
44+
port: ${{ secrets.WAS_SSH_PORT }}
45+
script: |
46+
docker stop mua-backend || true
47+
docker rm mua-backend || true
48+
docker pull ${{ secrets.DOCKERHUB_USERNAME }}/mua-backend:${{ github.sha }}
49+
docker run -d -p 8080:8080 --name mua-backend \
50+
${{ secrets.DOCKERHUB_USERNAME }}/mua-backend:${{ github.sha }}

‎.github/workflows/ci.yml‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches-ignore:
7+
- main
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
17+
- name: Set up JDK 17
18+
uses: actions/setup-java@v4
19+
with:
20+
java-version: '17'
21+
distribution: 'temurin'
22+
23+
- name: Grant execute permission
24+
run: chmod +x ./gradlew
25+
26+
- name: Build (no deploy)
27+
run: ./gradlew clean build -x test

‎.gitignore‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,8 @@ out/
3535

3636
### VS Code ###
3737
.vscode/
38+
39+
*.yml
40+
!application.yml
41+
!ci.yml
42+
!cd.yml

‎Dockerfile‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# 1. JDK 이미지를 기반으로 실행 환경 설정
2+
FROM eclipse-temurin:17-jdk-alpine
3+
4+
# 2. JAR 파일을 컨테이너 안으로 복사
5+
ARG JAR_FILE=build/libs/*.jar
6+
COPY ${JAR_FILE} app.jar
7+
8+
# 3. 컨테이너 실행 시 실행할 명령어
9+
ENTRYPOINT ["java","-jar","/app.jar"]

‎build.gradle‎

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,34 @@ repositories {
2525
}
2626

2727
dependencies {
28-
implementation 'org.springframework.boot:spring-boot-starter-web'
29-
compileOnly 'org.projectlombok:lombok'
30-
annotationProcessor 'org.projectlombok:lombok'
31-
testImplementation 'org.springframework.boot:spring-boot-starter-test'
32-
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
28+
29+
// Spring Boot
30+
implementation 'org.springframework.boot:spring-boot-starter'
31+
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
32+
implementation 'org.springframework.boot:spring-boot-starter-web'
33+
implementation 'org.springframework.boot:spring-boot-devtools'
34+
implementation 'org.springframework.boot:spring-boot-starter-validation'
35+
36+
// Test
37+
testImplementation 'org.springframework.boot:spring-boot-starter-test'
38+
39+
// Lombok
40+
compileOnly 'org.projectlombok:lombok'
41+
annotationProcessor 'org.projectlombok:lombok'
42+
43+
// Swagger
44+
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.7.0'
45+
46+
// Database
47+
runtimeOnly 'com.h2database:h2'
48+
runtimeOnly 'com.mysql:mysql-connector-j'
49+
50+
// Spring Security
51+
implementation 'org.springframework.boot:spring-boot-starter-security'
52+
53+
// AWS
54+
implementation 'io.awspring.cloud:spring-cloud-aws-starter-s3:3.3.0'
55+
3356
}
3457

3558
tasks.named('test') {
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package Mua.Mua_backend.global.annotation;
2+
3+
import Mua.Mua_backend.global.exception.ErrorCode;
4+
5+
import java.lang.annotation.ElementType;
6+
import java.lang.annotation.Retention;
7+
import java.lang.annotation.RetentionPolicy;
8+
import java.lang.annotation.Target;
9+
10+
@Target(ElementType.METHOD)
11+
@Retention(RetentionPolicy.RUNTIME)
12+
public @interface ApiExceptions {
13+
ErrorCode[] value();
14+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package Mua.Mua_backend.global.annotation;
2+
3+
import Mua.Mua_backend.global.common.EnumValidator;
4+
import jakarta.validation.Constraint;
5+
import jakarta.validation.Payload;
6+
7+
import java.lang.annotation.*;
8+
9+
@Target({ElementType.FIELD, ElementType.PARAMETER})
10+
@Retention(RetentionPolicy.RUNTIME)
11+
@Documented
12+
@Constraint(validatedBy = EnumValidator.class)
13+
public @interface EnumValid {
14+
15+
String message() default "";
16+
Class<?>[] groups() default {};
17+
Class<? extends Payload>[] payload() default {};
18+
Class<? extends Enum<?>> enumClass();
19+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package Mua.Mua_backend.global.common;
2+
3+
import jakarta.persistence.Column;
4+
import jakarta.persistence.EntityListeners;
5+
import jakarta.persistence.MappedSuperclass;
6+
import lombok.Getter;
7+
import org.springframework.data.annotation.CreatedDate;
8+
import org.springframework.data.annotation.LastModifiedDate;
9+
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
10+
11+
import java.time.LocalDateTime;
12+
13+
@Getter
14+
@EntityListeners(AuditingEntityListener.class)
15+
@MappedSuperclass
16+
public class BaseTimeEntity {
17+
18+
@CreatedDate
19+
@Column(updatable = false)
20+
private LocalDateTime createdDate;
21+
22+
@LastModifiedDate
23+
private LocalDateTime lastModifiedDate;
24+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package Mua.Mua_backend.global.common;
2+
3+
import Mua.Mua_backend.global.annotation.EnumValid;
4+
import jakarta.validation.ConstraintValidator;
5+
import jakarta.validation.ConstraintValidatorContext;
6+
7+
import java.util.Arrays;
8+
9+
public class EnumValidator implements ConstraintValidator<EnumValid, String> {
10+
11+
private Class<? extends Enum<?>> enumClass;
12+
13+
@Override
14+
public void initialize(EnumValid constraintAnnotation) {
15+
this.enumClass = constraintAnnotation.enumClass();
16+
}
17+
18+
@Override
19+
public boolean isValid(String value, ConstraintValidatorContext context) {
20+
if (value == null) {
21+
return true;
22+
}
23+
24+
return Arrays.stream(enumClass.getEnumConstants())
25+
.anyMatch(e -> e.name().equalsIgnoreCase(value)); // 대소문자 구분 없음
26+
}
27+
}

0 commit comments

Comments
 (0)