-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #73 from coffee-meet/dev
1차 배포
- Loading branch information
Showing
147 changed files
with
6,041 additions
and
43 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* @smart-sangmin @1o18z @yumyeonghan |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
addAssignees: author |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
name: coffee-meet CD | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
test_and_deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: 현재 작업중인 Repository 가져온다. | ||
uses: actions/checkout@v3 | ||
|
||
- name: CD 프로세스를 최적화 하기 위해 Gradle 정보를 캐싱한다. | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
~/.gradle/caches | ||
~/.gradle/wrapper | ||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | ||
restore-keys: | | ||
${{ runner.os }}-gradle- | ||
- name: JDK 17 설치한다. | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
|
||
- name: .env 파일에 깃 Secrets 로부터 값을 가져와 기록한다. | ||
run: echo "${{ secrets.ENV_PROPERTIES }}" > ./.env | ||
|
||
- name: Gradle 명령 실행을 위한 권한을 부여한다. | ||
run: chmod +x gradlew | ||
|
||
- name: Gradle test & build 를 수행한다. | ||
run: | | ||
./gradlew clean test -Pprofile=test | ||
./gradlew clean build | ||
- name: 현재 디렉토리에 있는 Dockerfile(Jar)을 이미지 빌드한다. | ||
run: docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/boot-prac-ci . | ||
|
||
- name: Docker Hub 에 로그인한다. | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: 빌드된 도커 이미지(Jar)를 Docker Hub 에 푸쉬한다. | ||
run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/boot-prac-ci:latest | ||
|
||
- name: ./.env 경로의 환경 변수 파일을 Ec2 서버의 기본 경로에 전달한다. | ||
uses: appleboy/scp-action@master | ||
with: | ||
username: ubuntu | ||
host: ${{ secrets.HOST }} | ||
key: ${{ secrets.PRIVATE_KEY }} | ||
source: "./.env" | ||
target: "/home/ubuntu" | ||
|
||
- name: 기존의 Jar 이미지를 삭제하고, Docker Hub 를 통해 새 Jar 이미지를 실행한다. | ||
uses: appleboy/[email protected] | ||
with: | ||
host: ${{ secrets.HOST }} | ||
username: ubuntu | ||
key: ${{ secrets.PRIVATE_KEY }} | ||
script: | | ||
sudo docker ps -q | grep -v $(sudo docker ps -qf "name=redis") | xargs -r sudo docker stop | ||
sudo docker ps -aq | grep -v $(sudo docker ps -aqf "name=redis") | xargs -r sudo docker rm | ||
sudo docker image prune -a -f | ||
sudo docker pull ${{ secrets.DOCKERHUB_USERNAME }}/boot-prac-ci:latest | ||
sudo docker run -d --log-driver=syslog --env-file .env -p 8080:8080 ${{ secrets.DOCKERHUB_USERNAME }}/boot-prac-ci:latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
name: coffee-meet CI | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
- dev | ||
|
||
jobs: | ||
test: | ||
name: Test | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
checks: write | ||
pull-requests: write | ||
|
||
steps: | ||
- name: 현재 작업중인 Repository 가져온다. | ||
uses: actions/checkout@v3 | ||
|
||
- name: CI 프로세스를 최적화 하기 위해 Gradle 정보를 캐싱한다. | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
~/.gradle/caches | ||
~/.gradle/wrapper | ||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | ||
restore-keys: | | ||
${{ runner.os }}-gradle- | ||
- name: JDK 17 설치한다. | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
|
||
- name: Gradle 명령 실행을 위한 권한을 부여한다. | ||
run: chmod +x gradlew | ||
|
||
- name: Gradle test를 수행한다. | ||
run: ./gradlew test | ||
|
||
- name: 테스트 결과를 PR 코멘트 등록한다. | ||
uses: EnricoMi/publish-unit-test-result-action@v2 | ||
if: always() | ||
with: | ||
files: '**/build/test-results/test/TEST-*.xml' | ||
|
||
- name: 테스트 실패 시 해당 코드 라인에 Check 등록한다. | ||
uses: mikepenz/action-junit-report@v3 | ||
if: always() | ||
with: | ||
report_paths: '**/build/test-results/test/TEST-*.xml' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
FROM openjdk:17-jdk-alpine | ||
ARG JAR_FILE=build/libs/*.jar | ||
COPY ${JAR_FILE} app.jar | ||
ENTRYPOINT ["java", "-jar", "app.jar"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,120 @@ | ||
import org.hidetake.gradle.swagger.generator.GenerateSwaggerUI | ||
|
||
buildscript { | ||
ext { | ||
restdocsApiSpecVersion = '0.18.3' // restdocsApiSpecVersion 버전 변수 설정 | ||
} | ||
} | ||
|
||
plugins { | ||
id 'java' | ||
id 'org.springframework.boot' version '3.1.4' | ||
id 'io.spring.dependency-management' version '1.1.3' | ||
id 'org.asciidoctor.jvm.convert' version '3.3.2' | ||
id 'java' | ||
id 'org.springframework.boot' version '3.1.4' | ||
id 'io.spring.dependency-management' version '1.1.3' | ||
id 'com.epages.restdocs-api-spec' version "${restdocsApiSpecVersion}" | ||
id 'org.hidetake.swagger.generator' version '2.18.2' | ||
} | ||
|
||
group = 'coffee-meet' | ||
version = '0.0.1-SNAPSHOT' | ||
|
||
java { | ||
sourceCompatibility = '17' | ||
sourceCompatibility = '17' | ||
} | ||
|
||
configurations { | ||
compileOnly { | ||
extendsFrom annotationProcessor | ||
} | ||
compileOnly { | ||
extendsFrom annotationProcessor | ||
} | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
mavenCentral() | ||
} | ||
|
||
ext { | ||
set('snippetsDir', file("build/generated-snippets")) | ||
set('snippetsDir', file("build/generated-snippets")) | ||
} | ||
|
||
dependencies { | ||
implementation 'org.springframework.boot:spring-boot-starter-data-jpa' | ||
implementation 'org.springframework.boot:spring-boot-starter-data-redis' | ||
implementation 'org.springframework.boot:spring-boot-starter-validation' | ||
implementation 'org.springframework.boot:spring-boot-starter-web' | ||
compileOnly 'org.projectlombok:lombok' | ||
runtimeOnly 'com.h2database:h2' | ||
runtimeOnly 'com.mysql:mysql-connector-j' | ||
annotationProcessor 'org.projectlombok:lombok' | ||
testImplementation 'org.springframework.boot:spring-boot-starter-test' | ||
testImplementation 'org.springframework.restdocs:spring-restdocs-mockmvc' | ||
/* Database */ | ||
implementation 'org.springframework.boot:spring-boot-starter-data-jpa' | ||
implementation 'org.springframework.boot:spring-boot-starter-data-redis' | ||
runtimeOnly 'com.mysql:mysql-connector-j' | ||
runtimeOnly 'com.h2database:h2' | ||
|
||
/* Spring */ | ||
implementation 'org.springframework.boot:spring-boot-starter-validation' | ||
implementation 'org.springframework.boot:spring-boot-starter-web' | ||
implementation 'org.springframework.boot:spring-boot-starter-mail' | ||
|
||
/* JWT */ | ||
implementation 'io.jsonwebtoken:jjwt-api:0.11.5' | ||
implementation 'io.jsonwebtoken:jjwt-impl:0.11.5' | ||
implementation 'io.jsonwebtoken:jjwt-jackson:0.11.5' | ||
|
||
/* Lombok */ | ||
compileOnly 'org.projectlombok:lombok' | ||
annotationProcessor 'org.projectlombok:lombok' | ||
|
||
/* Test */ | ||
testImplementation 'org.springframework.boot:spring-boot-starter-test' | ||
testImplementation group: 'org.instancio', name: 'instancio-junit', version: '3.0.0' | ||
|
||
/* TestContainer */ | ||
testImplementation "org.testcontainers:testcontainers:1.19.0" | ||
testImplementation "org.testcontainers:junit-jupiter:1.19.0" | ||
|
||
/* Docs & UI */ | ||
testImplementation 'org.springframework.restdocs:spring-restdocs-mockmvc' | ||
testImplementation "com.epages:restdocs-api-spec-mockmvc:${restdocsApiSpecVersion}" | ||
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.1.0' | ||
swaggerUI 'org.webjars:swagger-ui:4.11.1' | ||
|
||
/* Cloud */ | ||
implementation 'org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE' | ||
} | ||
|
||
tasks.named('test') { | ||
outputs.dir snippetsDir | ||
useJUnitPlatform() | ||
useJUnitPlatform() | ||
} | ||
|
||
swaggerSources { | ||
sample { | ||
setInputFile(file("${project.buildDir}/api-spec/openapi3.yaml")) | ||
} | ||
} | ||
|
||
openapi3 { | ||
servers = [ | ||
{ url = "http://localhost:8080" }, | ||
{ url = "http://13.209.253.204:8080" } | ||
] | ||
title = "API 문서" | ||
description = "RestDocsWithSwagger Docs" | ||
version = "0.0.1" | ||
format = "yaml" | ||
} | ||
|
||
tasks.withType(GenerateSwaggerUI) { | ||
dependsOn 'openapi3' | ||
doFirst { | ||
def swaggerUIFile = file("${openapi3.outputDirectory}/openapi3.yaml") | ||
|
||
def securitySchemesContent = " securitySchemes:\n" + \ | ||
" APIKey:\n" + \ | ||
" type: apiKey\n" + \ | ||
" name: Authorization\n" + \ | ||
" in: header\n" + \ | ||
"security:\n" + | ||
" - APIKey: [] # Apply the security scheme here" | ||
|
||
swaggerUIFile.append securitySchemesContent | ||
} | ||
} | ||
|
||
tasks.named('asciidoctor') { | ||
inputs.dir snippetsDir | ||
dependsOn test | ||
bootJar { | ||
dependsOn generateSwaggerUISample | ||
from("${generateSwaggerUISample.outputDir}") { | ||
into 'static/docs' | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package coffeemeet.server.admin.domain; | ||
|
||
import coffeemeet.server.common.entity.BaseEntity; | ||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.Table; | ||
import lombok.AccessLevel; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Entity | ||
@Getter | ||
@Table(name = "admins") | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class Admin extends BaseEntity { | ||
|
||
@Id | ||
@Column(nullable = false) | ||
private String id; | ||
|
||
@Column(nullable = false) | ||
private String password; | ||
|
||
} |
37 changes: 37 additions & 0 deletions
37
src/main/java/coffeemeet/server/auth/controller/AuthController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package coffeemeet.server.auth.controller; | ||
|
||
import coffeemeet.server.auth.domain.AuthTokens; | ||
import coffeemeet.server.auth.service.AuthService; | ||
import coffeemeet.server.common.annotation.Login; | ||
import coffeemeet.server.user.controller.dto.AuthInfo; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/api/v1/auth") | ||
public class AuthController { | ||
|
||
private final AuthService authService; | ||
|
||
@PostMapping("/renew-token") | ||
public ResponseEntity<AuthTokens> renew(@Login AuthInfo authInfo) { | ||
return ResponseEntity.ok(authService.renew(authInfo.userId(), authInfo.refreshToken())); | ||
} | ||
|
||
@PostMapping("/logout") | ||
public ResponseEntity<Void> logout(@Login AuthInfo authInfo) { | ||
authService.logout(authInfo.userId()); | ||
return ResponseEntity.ok().build(); | ||
} | ||
|
||
@PostMapping("/delete") | ||
public ResponseEntity<Void> delete(@Login AuthInfo authInfo) { | ||
authService.delete(authInfo.userId()); | ||
return ResponseEntity.ok().build(); | ||
} | ||
|
||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/coffeemeet/server/auth/domain/AuthTokens.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package coffeemeet.server.auth.domain; | ||
|
||
public record AuthTokens( | ||
String accessToken, | ||
String refreshToken | ||
) { | ||
|
||
public static AuthTokens of( | ||
String accessToken, | ||
String refreshToken | ||
) { | ||
return new AuthTokens( | ||
accessToken, | ||
refreshToken | ||
); | ||
} | ||
|
||
} |
Oops, something went wrong.