Skip to content

Commit

Permalink
Merge pull request #27 from s2hoon/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
s2hoon authored Mar 30, 2024
2 parents 9e81597 + 47c76fc commit 9904f10
Show file tree
Hide file tree
Showing 88 changed files with 2,136 additions and 1,186 deletions.
120 changes: 120 additions & 0 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle

name: Java CI with Gradle

on:
push:
branches:
- main
- develop
pull_request:
branches: [ "main" ]

permissions:
contents: read

jobs:
build:

runs-on: ubuntu-latest

steps:


- uses: actions/checkout@v3
- name: Set up JDK 19
uses: actions/setup-java@v3
with:
java-version: '19'
distribution: 'temurin'
## gradle caching
- name: Gradle Caching
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
## create application-dev.properties
- name: make application-dev.properties
if: contains(github.ref, 'develop')
run: |
cd ./src/main/resources
touch ./application-dev.properties
echo "${{ secrets.PROPERTIES_DEV }}" > ./application-dev.properties
shell: bash

## create application-prod.properties
- name: make application-prod.properties
if: contains(github.ref, 'main') # branch가 main 일 때, 나머지는 위와 동일
run: |
cd ./src/main/resources
touch ./application-prod.properties
echo "${{ secrets.PROPERTIES_PROD }}" > ./application-prod.properties
shell: bash

## gradle build
- name: Build with Gradle
run: ./gradlew build -x test

## docker build & push to production
- name: Docker build & push to prod
if: contains(github.ref, 'main')
run: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker build -f Dockerfile-prod -t ${{ secrets.DOCKER_USERNAME }}/dub-prod .
docker push ${{ secrets.DOCKER_USERNAME }}/dub-prod
## docker build & push to develop
- name: Docker build & push to dev
if: contains(github.ref, 'develop')
run: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker build -f Dockerfile-dev -t ${{ secrets.DOCKER_USERNAME }}/dub-dev .
docker push ${{ secrets.DOCKER_USERNAME }}/dub-dev
## deploy to production
- name: Deploy to prod
uses: appleboy/ssh-action@master
id: deploy-prod
if: contains(github.ref, 'main')
with:
host: ${{ secrets.HOST_PROD }}
username: ubuntu
key: ${{ secrets.SSH_KEY }}
envs: GITHUB_SHA
script: |
sudo docker stop dub
sudo docker rm dub
sudo docker pull ${{ secrets.DOCKER_USERNAME }}/dub-prod
sudo docker run -d -p 8080:8080 --name dub ${{ secrets.DOCKER_USERNAME }}/dub-prod
sudo docker image prune -f
## deploy to develop
- name: Deploy to dev
uses: appleboy/ssh-action@master
id: deploy-dev
if: contains(github.ref, 'develop')
with:
host: ${{ secrets.HOST_DEV }}
username: ec2-user
key: ${{ secrets.SSH_KEY }}
port: 22
#key: ${{ secrets.PRIVATE_KEY }}
script: |
sudo docker stop dub-dev
sudo docker rm -fv dub-dev
sudo docker pull ${{ secrets.DOCKER_USERNAME }}/dub-dev
sudo docker run -d -p 8080:8080 ${{ secrets.DOCKER_USERNAME }}/dub-dev
sudo docker image prune -f
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,6 @@ out/


##application.properties##
application.properties
application.properties
application-dev.properties
application-prod.properties
6 changes: 6 additions & 0 deletions Dockerfile-dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## Dockerfile-dev
FROM openjdk:19-alpine
EXPOSE 8080
ARG JAR_FILE=/build/libs/dub-0.0.1-SNAPSHOT.jar
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","-jar","-Dspring.profiles.active=dev","/app.jar"]
6 changes: 6 additions & 0 deletions Dockerfile-prod
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## Dockerfile-prod
FROM openjdk:19-alpine
EXPOSE 8080
ARG JAR_FILE=/build/libs/dub-0.0.1-SNAPSHOT.jar
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","-jar","-Dspring.profiles.active=prod","/app.jar"]
61 changes: 60 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,61 @@
---


# dub_club_wanted_BE
동아리 버전 원티드

## dub
동아리 홍보와, 동아리 지원을 할수있는 플랫폼


---

# 핵심기능

#### 1. 회원 가입

```일반 회원과 동아리 회원으로 나누어 가입이 가능합니다.```

#### 2. 동아리 등록

```동아리 회원은 동아리의 프로필 이미지, 태그, 소개글 등을 등록할 수 있습니다.```

#### 3. 동아리 공고 및 지원서 양식 등록

```동아리 회원은 동아리 내에서 공고를 올릴 수 있으며, 지원자들에게 지원서 양식을 제공할 수 있습니다.```

#### 4. 태그별 동아리 조회

```사용자는 태그별로 동아리를 검색하고 조회할 수 있습니다.```

#### 5. 동아리 지원서 다운로드 및 제출

```일반 회원은 동아리의 지원서 양식을 다운로드하여 작성한 후, 해당 동아리에 제출할 수 있습니다.```

#### 6. 동아리 회원별 지원자 조회

```동아리 회원은 자신의 동아리에 지원한 회원들을 조회할 수 있습니다.```

#### 7. 합격/불합격 통보 보내기

```동아리 회원은 지원자들에게 합격 또는 불합격 통보를 보낼 수 있습니다.```

---

# API 엔드포인트 목록 및 사용법

---

# CI/CD Flow

![CIcd](https://github.com/s2hoon/dub_club_wanted_BE/assets/82464990/120399f7-7d09-4996-a8ac-631c4024a4fe)

1. main branch 에 Push 또는 Merge
2. Github 에 작성해둔 workflow file 로 Github Actions 수행
3. build, docker image build, docker image push 수행
4. EC2 인스턴스에서 docker image pull 후, run

---

# ERD

![erd](https://github.com/s2hoon/dub_club_wanted_BE/assets/82464990/d333d553-4d3a-45b5-a492-7f9ee254873e)
67 changes: 38 additions & 29 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,48 +1,57 @@
plugins {
id 'java'
id 'org.springframework.boot' version '3.0.4'
id 'io.spring.dependency-management' version '1.1.0'
id 'java'
id 'org.springframework.boot' version '3.0.4'
id 'io.spring.dependency-management' version '1.1.0'
}

group = 'com.likelion'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '19'

configurations {
compileOnly {
extendsFrom annotationProcessor
}
compileOnly {
extendsFrom annotationProcessor
}
}

repositories {
mavenCentral()
mavenCentral()
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'mysql:mysql-connector-java:8.0.26'
implementation 'org.springframework.boot:spring-boot-starter-security'
compileOnly 'org.projectlombok:lombok'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
annotationProcessor 'org.projectlombok:lombok'
runtimeOnly 'com.mysql:mysql-connector-j'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
// 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'
implementation 'commons-io:commons-io:2.6'


//swagger
implementation 'io.springfox:springfox-boot-starter:3.0.0'
implementation group: 'io.springfox', name: 'springfox-swagger-ui', version: '3.0.0'

// json 요청
implementation group: 'org.json', name: 'json', version: '20210307'
// spring
implementation 'org.springframework:spring-web'
// spring boot
developmentOnly 'org.springframework.boot:spring-boot-devtools'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-security'
// mysql
implementation 'mysql:mysql-connector-java:8.0.26'
runtimeOnly 'com.mysql:mysql-connector-j'
// lombok
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
// 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'
implementation 'commons-io:commons-io:2.6'

// s3
implementation 'org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE'
// test
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'

//thymeleaf
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf:3.0.1'

}

tasks.named('test') {
useJUnitPlatform()
useJUnitPlatform()
}
Empty file modified gradlew
100644 → 100755
Empty file.
Binary file removed images/20230330/691422510048300.png
Binary file not shown.
Binary file removed images/20230330/82016473748200.png
Binary file not shown.
11 changes: 7 additions & 4 deletions src/main/java/com/likelion/dub/DubApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;


@EnableJpaAuditing
@SpringBootApplication
public class DubApplication {

public static void main(String[] args) {
SpringApplication.run(DubApplication.class, args);
}

public static void main(String[] args) {
SpringApplication.run(DubApplication.class, args);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.likelion.dub.common;
package com.likelion.dub.baseResponse;

import lombok.AllArgsConstructor;
import lombok.Getter;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package com.likelion.dub.common;
package com.likelion.dub.baseResponse;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import lombok.Getter;

import static com.likelion.dub.common.BaseResponseStatus.SUCCESS;

@Getter
@JsonPropertyOrder({"isSuccess", "code", "message", "result"})
public class BaseResponse<T> {
Expand All @@ -23,24 +21,15 @@ public class BaseResponse<T> {
private T result;

// 요청 성공
public BaseResponse(T result) {
this.isSuccess = SUCCESS.isSuccess();
this.code = SUCCESS.getCode();
this.message = SUCCESS.getMessage();
public BaseResponse(BaseResponseStatus status, T result) {
this(status);
this.result = result;
}

// 요청에 실패한 경우
// 요청 실패
public BaseResponse(BaseResponseStatus status) {
this.isSuccess = status.isSuccess();
this.code = status.getCode();
this.message = status.getMessage();
}

public BaseResponse(T result, BaseResponseStatus existsLike) {
this.isSuccess = existsLike.isSuccess();
this.code = existsLike.getCode();
this.message = existsLike.getMessage();
this.result = result;
}
}
Loading

0 comments on commit 9904f10

Please sign in to comment.