Skip to content

Commit

Permalink
Merge pull request #1 from hangillee/develop/be-1
Browse files Browse the repository at this point in the history
Develop/be 1
  • Loading branch information
hangillee authored Aug 20, 2024
2 parents a2bf5f2 + db3dae0 commit a4b07c6
Show file tree
Hide file tree
Showing 191 changed files with 10,741 additions and 52 deletions.
9 changes: 9 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# ✅ 작업 내용

- 작업 내용 1
- 작업 내용 2
- 작업 내용 3

# 📸 스크린샷

# 🙈 참고 사항
67 changes: 67 additions & 0 deletions .github/workflows/be-cd-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: BE CD DEV

on:
push:
branches: [ develop/be ]

jobs:
build:
runs-on: ubuntu-latest

defaults:
run:
shell: bash
working-directory: ./backend

steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'

- name: Make keystore file
run: echo "${{secrets.SSL_KEYSTORE}}" | base64 --decode > ./src/main/resources/keystore.p12

- 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-
- name: Setup Gradle
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5

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

- name: Build with Gradle
run: ./gradlew clean build

- name: Sign in Dockerhub
uses: docker/login-action@v1
with:
username: ${{secrets.DOCKER_USERNAME}}
password: ${{secrets.DOCKER_PASSWORD}}

- name: Build the Docker image
run: docker build -f ./Dockerfile --platform linux/arm64 --no-cache -t touroot/touroot-api .

- name: Push the Docker Image to Dockerhub
run: docker push touroot/touroot-api

deploy:
needs: build
runs-on: self-hosted

steps:
- name: Docker Image pull
run: sudo docker pull touroot/touroot-api

- name: Docker Compose up
run: sudo docker compose -f ~/docker/touroot-docker.yml up -d
57 changes: 57 additions & 0 deletions .github/workflows/be-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: BE CI

on:
pull_request:
branches: [ production/be, develop/be ]

jobs:
build:
runs-on: ubuntu-latest

defaults:
run:
shell: bash
working-directory: ./backend

steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'

- name: Make keystore file
run: echo "${{secrets.SSL_KEYSTORE}}" | base64 --decode > ./src/main/resources/keystore.p12

- 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-
- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Test with Gradle
run: ./gradlew build

- name: Publish Unit Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
if: ${{ always() }}
with:
files: ${{ github.workspace }}/backend/build/test-results/**/*.xml
seconds_between_github_reads: 1.0
seconds_between_github_writes: 3.0
secondary_rate_limit_wait_seconds: 90.0

- name: When test fail, comment on that code
uses: mikepenz/action-junit-report@v3
if: always()
with:
report_paths: ${{ github.workspace }}/backend/build/test-results/**/*.xml
token: ${{ github.token }}
67 changes: 67 additions & 0 deletions .github/workflows/be-prod-cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: BE CD PROD

on:
push:
branches: [ production/be ]

jobs:
build:
runs-on: ubuntu-latest

defaults:
run:
shell: bash
working-directory: ./backend

steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'

- name: Make keystore file
run: echo "${{secrets.PROD_SSL_KEYSTORE}}" | base64 --decode > ./src/main/resources/keystore.p12

- 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-
- name: Setup Gradle
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5

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

- name: Build with Gradle
run: ./gradlew clean build

- name: Sign in Dockerhub
uses: docker/login-action@v1
with:
username: ${{secrets.DOCKER_USERNAME}}
password: ${{secrets.DOCKER_PASSWORD}}

- name: Build the Docker image
run: docker build -f ./Dockerfile --platform linux/arm64 --no-cache -t touroot/touroot-api:prod .

- name: Push the Docker Image to Dockerhub
run: docker push touroot/touroot-api:prod

deploy:
needs: build
runs-on: [self-hosted, prod]

steps:
- name: Docker Image pull
run: sudo docker pull touroot/touroot-api:prod

- name: Docker Compose up
run: sudo docker compose -f ~/docker/api-docker.yml up -d
2 changes: 2 additions & 0 deletions backend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
build

**/.DS_Store
/log
/src/main/resources/keystore.p12
4 changes: 4 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM openjdk:17-oracle
ARG JAR_FILE=build/libs/*.jar
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java", "-jar", "-Duser.timezone=Asia/Seoul", "/app.jar"]
68 changes: 47 additions & 21 deletions backend/build.gradle
Original file line number Diff line number Diff line change
@@ -1,40 +1,66 @@
plugins {
id 'java'
id 'org.springframework.boot' version '3.3.1'
id 'io.spring.dependency-management' version '1.1.5'
id 'java'
id 'org.springframework.boot' version '3.3.1'
id 'io.spring.dependency-management' version '1.1.5'
}

group = 'woowacourse'
group = 'kr.touroot'
version = '0.0.1-SNAPSHOT'

java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}

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-validation'
implementation 'org.springframework.boot:spring-boot-starter-web'
compileOnly 'org.projectlombok:lombok'
runtimeOnly 'com.mysql:mysql-connector-j'
annotationProcessor 'org.projectlombok:lombok'
runtimeOnly 'com.h2database:h2'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.6.0'
implementation 'com.github.ulisesbocchio:jasypt-spring-boot-starter:3.0.4'
implementation 'io.jsonwebtoken:jjwt-api:0.11.5'
runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.11.5'
runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.11.5'

implementation 'software.amazon.awssdk:s3:2.20.28'
implementation 'software.amazon.awssdk:sts:2.20.28'
implementation 'software.amazon.awssdk:auth:2.20.28'
implementation 'io.findify:s3mock_2.13:0.2.6'

compileOnly 'org.projectlombok:lombok'
runtimeOnly 'com.mysql:mysql-connector-j'
annotationProcessor 'org.projectlombok:lombok'
runtimeOnly 'com.h2database:h2'

testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'io.rest-assured:rest-assured:5.5.0'
testImplementation 'io.findify:s3mock_2.13:0.2.6'
testCompileOnly 'org.projectlombok:lombok'
testAnnotationProcessor 'org.projectlombok:lombok'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'

// cache
implementation 'org.springframework.boot:spring-boot-starter-cache'
implementation("com.github.ben-manes.caffeine:caffeine:3.1.8")

// QueryDSL
implementation 'com.querydsl:querydsl-jpa:5.0.0:jakarta'
annotationProcessor 'com.querydsl:querydsl-apt:5.0.0:jakarta'
annotationProcessor "jakarta.annotation:jakarta.annotation-api"
annotationProcessor "jakarta.persistence:jakarta.persistence-api"
}

tasks.named('test') {
useJUnitPlatform()
useJUnitPlatform()
}
Binary file modified backend/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion backend/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
5 changes: 4 additions & 1 deletion backend/gradlew
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

##############################################################################
#
Expand Down Expand Up @@ -84,7 +86,8 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down
Loading

0 comments on commit a4b07c6

Please sign in to comment.