Skip to content

Commit

Permalink
Merge pull request #99 from kookmin-sw/milestone/#4
Browse files Browse the repository at this point in the history
Milestone/#4
  • Loading branch information
J-Yong99 authored Apr 19, 2024
2 parents 2a192e6 + b642864 commit 29507e0
Show file tree
Hide file tree
Showing 261 changed files with 22,031 additions and 530 deletions.
86 changes: 86 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: Deploy

on:
push:
branches:
- deploy/v1

jobs:
build:
runs-on: ubuntu-latest
env:
working-directory: ./backend/moment/moment-server

steps:

- name: Checkout code
uses: actions/checkout@v2


- name: Set up Java
uses: actions/setup-java@v2
with:
java-version: 17 # 원하는 Java 버전으로 변경
distribution: 'temurin'

- uses: actions/checkout@v3

- run: touch ./backend/moment/moment-server/auth/src/main/resources/application.properties
- run: echo "${{ secrets.AUTH_PROPERTIES }}" > ./backend/moment/moment-server/auth/src/main/resources/application.properties

- run: touch ./backend/moment/moment-server/core/src/main/resources/application.properties
- run: echo "${{ secrets.CORE_PROPERTIES }}" > ./backend/moment/moment-server/core/src/main/resources/application.properties

- run: touch ./backend/moment/moment-server/mail/src/main/resources/application.properties
- run: echo "${{ secrets.MAIL_PROPERTIES }}" > ./backend/moment/moment-server/mail/src/main/resources/application.properties

- run: touch ./backend/moment/moment-server/scheduler/src/main/resources/application.properties
- run: echo "${{ secrets.SCHEDULER_PROPERTIES }}" > ./backend/moment/moment-server/scheduler/src/main/resources/application.properties


# - run: cat ./src/main/resources/application.properties

- name: Grant execute permission for gradlew
run: chmod +x gradlew

#
# - name: Build with Gradle
# uses: gradle/gradle-build-action@v2
# with:
# arguments: build -x test
# build-root-directory: ./backend/moment/moment-server
# gradle-version: 7.5
#
# - name: Deploy to Server
# uses: actions/checkout@v3

# - run: |
# docker-compose up --build
# working-directory: ${{ env.working-directory }}

# 서버에 애플리케이션 배포 스크립트 실행
# 예: scp, SSH, Docker, Kubernetes 등을 사용하여 배포
deploy:
env:
working-directory: ./backend/moment/moment-server
runs-on: ubuntu-latest
needs:
- build
steps:
- uses: actions/checkout@v3
- name: Add Server key
run: |
touch key.txt
echo "${{ secrets.SERVER_KEY }}" > key.txt
chmod 600 key.txt
working-directory: ${{ env.working-directory }}
- name: Deploy the application
env:
SERVER_HOST: ${{ secrets.SERVER_HOST }}
SERVER_PORT: ${{ secrets.SERVER_PORT }}
SERVER_USER: ${{ secrets.SERVER_USER }}
run: |
chmod 755 ./deploy.sh
set -e
./deploy.sh
working-directory: ${{ env.working-directory }}
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/capstone-2024-22.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 14 additions & 11 deletions backend/moment/moment-server/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@
*.tar.gz
*.rar

!**/gradle-wrapper.jar
!**/gradle-wrapper.properties

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
replay_pid*

*.properties

/.gradle/8.5/fileHashes/fileHashes.bin
/.gradle/buildOutputCleanup/buildOutputCleanup.lock
/.gradle/8.5/checksums/checksums.lock
Expand All @@ -34,15 +37,15 @@ replay_pid*
/.gradle/file-system.probe
/.gradle/8.5/fileHashes/fileHashes.lock
/.idea/gradle.xml
/core/gradle/wrapper/gradle-wrapper.jar
/eureka/gradle/wrapper/gradle-wrapper.jar
/gateway/gradle/wrapper/gradle-wrapper.jar
/core/gradlew
/eureka/gradlew
/gateway/gradlew
/core/gradlew.bat
/eureka/gradlew.bat
/gateway/gradlew.bat
#/core/gradle/wrapper/gradle-wrapper.jar
#/eureka/gradle/wrapper/gradle-wrapper.jar
#/gateway/gradle/wrapper/gradle-wrapper.jar
#/core/gradlew
#/eureka/gradlew
#/gateway/gradlew
#/core/gradlew.bat
#/eureka/gradlew.bat
#/gateway/gradlew.bat
/.idea/jarRepositories.xml
/.idea/jpa-buddy.xml
/.gradle/8.5/fileChanges/last-build.bin
Expand All @@ -57,6 +60,6 @@ replay_pid*
/.idea/modules/eureka/root.eureka.main.iml
/.gradle/8.5/checksums/sha1-checksums.bin
/.idea/vcs.xml
/ai/gradlew
#/ai/gradlew
.DS_Store
*/.DS_Store
30 changes: 30 additions & 0 deletions backend/moment/moment-server/auth/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# 도커 허브에서 공식적으로 제공하는 OpenJDK 이미지를 베이스 이미지로 사용합니다.
FROM openjdk:17-jdk-slim

# 빌드에 필요한 패키지를 설치합니다.
RUN apt-get update && apt-get install -y findutils && rm -rf /var/lib/apt/lists/*

# 작업 디렉토리를 생성합니다.
RUN mkdir -p /app
WORKDIR /app

# Gradle 캐시를 미리 복사하여 의존성 다운로드 시간을 단축합니다.
#COPY .gradle .gradle

# 프로젝트 소스 코드와 Gradle 설정 파일을 복사합니다.
COPY build.gradle gradlew ./
COPY gradle gradle
COPY src src

# Gradle을 이용하여 프로젝트를 빌드합니다.
RUN --mount=type=cache,target=/root/.gradle ./gradlew build -x test

# 빌드 결과물을 Docker 이미지 안에 포함시킵니다. 이건 호스트에서 가져올떄 COPY고 컨테이너 내부에서 빌드한 파일을 복사할때 cp
#COPY build/libs/*SNAPSHOT.jar app.jar
RUN cp build/libs/*SNAPSHOT.jar app.jar


# 컨테이너가 실행될 때 자동으로 실행할 명령어를 설정합니다.
CMD ["java", "-jar", "app.jar"]


36 changes: 36 additions & 0 deletions backend/moment/moment-server/auth/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ plugins {
id 'java'
id 'org.springframework.boot' version '3.1.7'
id 'io.spring.dependency-management' version '1.1.4'
id "org.asciidoctor.jvm.convert" version "3.3.2"
}

group = 'com.moment'
Expand All @@ -15,6 +16,7 @@ configurations {
compileOnly {
extendsFrom annotationProcessor
}
asciidoctorExt // asciidoctorExt에 대한 선언
}

repositories {
Expand All @@ -39,9 +41,15 @@ dependencies {
implementation 'javax.xml.bind:jaxb-api:2.3.0'
implementation 'commons-io:commons-io:2.11.0'
implementation group: 'com.googlecode.json-simple', name: 'json-simple', version: '1.1.1'

testImplementation group: 'org.assertj', name: 'assertj-core', version: '3.21.0'
asciidoctorExt 'org.springframework.restdocs:spring-restdocs-asciidoctor' // asciidoctorExt에 spring-restdocs-asciidoctor 의존성 추가
testImplementation 'org.springframework.restdocs:spring-restdocs-mockmvc' // mockMvc 사용

}
ext {
set('springCloudVersion', "2022.0.3")
snippetsDir = file('build/generated-snippets') // 스니펫이 생성되는 디렉터리 경로를 설정
}

dependencyManagement {
Expand All @@ -53,3 +61,31 @@ dependencyManagement {
tasks.named('test') {
useJUnitPlatform()
}
//asciidoctor { // Gradle이 asciidoctor Task를 수행하는 설정 (함수 선언)
// configurations 'asciidoctorExt' // asciidoctor 확장 설정
// baseDirFollowsSourceFile() // .adoc 파일을 include 하면서 사용하기 위한 설정
// inputs.dir snippetsDir // 스니펫을 불러올 위치 설정
// dependsOn test // Gradle의 test Task 이후 asciidoctor를 수행
//}
//
//asciidoctor.doFirst { // asciidoctor Task가 수행될 때 가장 먼저 수행
// delete file('src/main/resources/static/docs')
//}
//
//task copyDocument(type: Copy) { // 생성된 html 파일을 옮긴다
// dependsOn asciidoctor // Gradle의 asciidoctor Task 이후 수행
// from file("${asciidoctor.outputDir}")
// into file("src/main/resources/static/docs")
//}
//
//build {
// dependsOn copyDocument // build 이후 html 파일 복사
//}
//
//bootJar {
// dependsOn asciidoctor // asciidoctor 이후 bootJar 수행
// from ("${asciidoctor.outputDir}") {
// into 'static/docs'
// }
//
//}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#
# Copyright 2012-2024 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
14 changes: 14 additions & 0 deletions backend/moment/moment-server/auth/src/docs/asciidoc/Auth.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
== Auth
:doctype: book
:source-highlighter: highlightjs
:sectlinks:
:toc: left
:toclevels: 3
=== 로그인
operation::auth/login[snippets="http-request,request-body,request-fields,http-response,response-fields"]
=== 비밀번호 변경
operation::auth/changePassword[snippets="http-request,request-headers,request-body,request-fields,http-response,response-fields"]
=== 인증코드 요청
operation::auth/sendCode[snippets="http-request,request-body,request-fields,http-response,response-fields"]
=== 인증코드 확인
operation::auth/verifyCode[snippets="http-request,request-headers,request-body,request-fields,http-response,response-fields"]
10 changes: 10 additions & 0 deletions backend/moment/moment-server/auth/src/docs/asciidoc/index.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// index.adoc
= Moment Application API Document
:doctype: book
:source-highlighter: highlightjs
:sectlinks:
:toc: left
:toclevels: 3

include::Auth.adoc[]

Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@


import jakarta.validation.constraints.NotEmpty;
import lombok.Getter;
import lombok.Setter;

import lombok.*;


public class AuthRequest {

//자체회원가입 폼
@Getter
@Setter
@Builder
public static class Login {

private String email;
Expand All @@ -23,19 +22,26 @@ public static class Login {

@Getter
@Setter
@Builder
public static class SendCode {
private String email;
private boolean isSignUp;
private String isSignUp;
}

@Getter
@Setter
@Builder
@AllArgsConstructor
@NoArgsConstructor
public static class VerifyCode {
private String code;
}

@Getter
@Setter
@Builder
@AllArgsConstructor
@NoArgsConstructor
public static class ChangePassword {

private String code;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ public TokenResponseDTO.GetToken login(AuthRequest.Login login) {

@Transactional
public TokenResponseDTO.GetTempToken sendCode(AuthRequest.SendCode sendCode) {
if (sendCode.isSignUp()) {
log.info("sendCode.isSignUp : {}", sendCode.getIsSignUp());
if (sendCode.getIsSignUp().equals("true")) {
if(userRepository.existsByEmail(sendCode.getEmail())){
throw new AlreadyRegisteredEmailException("이미 가입된 이메일");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ eureka:
register-with-eureka: true
fetch-registry: true
service-url:
# defaultZone: http://host.docker.internal:8761/eureka
defaultZone: http://localhost:8761/eureka
defaultZone: http://wasuphj.synology.me:8761/eureka
# defaultZone: http://localhost:8761/eureka
# instance:
# instance-id: ${spring.application.name}:${spring.application.instance_id:${random.value}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.moment.auth.config;

import org.springframework.restdocs.snippet.Attributes;

import static org.springframework.restdocs.snippet.Attributes.key;

public interface DocumentFormatGenerator {

static Attributes.Attribute getDateFormat() { // (2)
return key("format").value("yyyy-MM-dd");
}

static Attributes.Attribute getDateTimeFormat() { // (2)
return key("format").value("yyyy-MM-dd'T'HH:mm:ss");
}

static Attributes.Attribute getBooleanFormat() { // (3)
return key("format").value("true or false");
}
}
Loading

0 comments on commit 29507e0

Please sign in to comment.