Skip to content

Commit

Permalink
Release : 솔리투어 v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Astin01 committed Sep 24, 2024
1 parent cc47ea8 commit 0ab9a5c
Show file tree
Hide file tree
Showing 259 changed files with 11,641 additions and 32 deletions.
90 changes: 90 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: Docker Image CI

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

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Github Repository 에 올린 파일들을 볼러오기
uses: actions/checkout@v4

- name: JDK 17 버전 설치
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17

- name: application.yml 파일 만들기
run: |
mkdir -p ./src/main/resources
echo "${{ secrets.APPLICATION_YML }}" > ./src/main/resources/application.yml
echo "${{ secrets.APPLICATION_COMMON }}" > ./src/main/resources/application-common.yml
echo "${{ secrets.APPLICATION_DEV }}" > ./src/main/resources/application-dev.yml
echo "${{ secrets.APPLICATION_PROD }}" > ./src/main/resources/application-prod.yml
echo "${{ secrets.APPLICATION_LOCAL }}" > ./src/main/resources/application-local.yml
echo "${{ secrets.APPLICATION_TEST }}" > ./src/main/resources/application-test.yml
- name: gradlew 실행 권한 부여
run: chmod +x ./gradlew

- name: 테스트 및 빌드하기 (main 브랜치)
if: github.ref == 'refs/heads/main'
run: ./gradlew clean build -PspringProfile=prod --warning-mode all --scan

- name: 테스트 및 빌드하기 (develop 브랜치)
if: github.ref == 'refs/heads/develop'
run: |
./gradlew clean test -PspringProfile=test
./gradlew build -x test -PspringProfile=dev --warning-mode all --scan
- name: 빌드된 파일 이름 변경
run: mv ./build/libs/*SNAPSHOT.jar ./project.jar

- name: SCP로 EC2에 빌드된 파일 전송
uses: appleboy/[email protected]
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USERNAME }}
key: ${{ secrets.EC2_PRIVATE_KEY }}
source: project.jar
target: /home/ubuntu/solitour-server/tobe

- name: SSH로 EC2 접속
if: github.ref == 'refs/heads/main'
uses: appleboy/[email protected]
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USERNAME }}
key: ${{ secrets.EC2_PRIVATE_KEY }}
script_stop: true
script: |
rm -rf /home/ubuntu/solitour-server/current
mkdir /home/ubuntu/solitour-server/current
mv /home/ubuntu/solitour-server/tobe/project.jar /home/ubuntu/solitour-server/current/project.jar
cd /home/ubuntu/solitour-server/current
sudo fuser -k -n tcp 8080 || true
nohup java -jar -Dspring.profiles.active=prod project.jar & > ./output.log 2>&1 &
rm -rf /home/ubuntu/solitour-server/tobe
- name: SSH로 EC2 접속
if: github.ref == 'refs/heads/develop'
uses: appleboy/[email protected]
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USERNAME }}
key: ${{ secrets.EC2_PRIVATE_KEY }}
script_stop: true
script: |
rm -rf /home/ubuntu/solitour-server/current
mkdir /home/ubuntu/solitour-server/current
mv /home/ubuntu/solitour-server/tobe/project.jar /home/ubuntu/solitour-server/current/project.jar
cd /home/ubuntu/solitour-server/current
sudo fuser -k -n tcp 8080 || true
nohup java -jar -Dspring.profiles.active=dev project.jar > ./output.log 2>&1 &
rm -rf /home/ubuntu/solitour-server/tobe
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -174,4 +174,11 @@ Temporary Items
.apdisk

# idea 전부 무시
.idea/**
.idea/**

# local docker db 파일
/docker/db/

# 설정 파일
/src/main/resources/**.yml
/src/main/resources
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "gradle/wrapper/config"]
path = gradle/wrapper/config
url = https://github.com/TripInfoWeb/config.git
76 changes: 50 additions & 26 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,52 +1,76 @@
plugins {
id 'java'
id 'org.springframework.boot' version '3.3.0'
id 'io.spring.dependency-management' version '1.1.5'
id 'org.asciidoctor.jvm.convert' version '3.3.2'
id 'java'
id 'org.springframework.boot' version '3.3.0'
id 'io.spring.dependency-management' version '1.1.5'
id 'org.asciidoctor.jvm.convert' version '3.3.2'
}

group = 'solitour-backend'
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()
}

ext {
set('snippetsDir', file("build/generated-snippets"))
set('snippetsDir', file("build/generated-snippets"))
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jdbc'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-jdbc'
implementation 'org.springframework.boot:spring-boot-starter-web'
compileOnly 'org.projectlombok:lombok'
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'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-data-jdbc'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-validation'


implementation 'io.jsonwebtoken:jjwt-api:0.12.6'
runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.12.6'
runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.12.6'

implementation 'org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
testAnnotationProcessor 'org.projectlombok:lombok'

implementation 'org.mapstruct:mapstruct:1.5.5.Final'
annotationProcessor 'org.mapstruct:mapstruct-processor:1.5.5.Final'

implementation 'com.querydsl:querydsl-jpa:5.0.0:jakarta'
// queryDsl 라이브러리
annotationProcessor "com.querydsl:querydsl-apt:5.0.0:jakarta"
annotationProcessor "jakarta.annotation:jakarta.annotation-api"
annotationProcessor "jakarta.persistence:jakarta.persistence-api"

runtimeOnly 'com.mysql:mysql-connector-j'

testImplementation 'com.h2database:h2'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.restdocs:spring-restdocs-mockmvc'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}

tasks.named('test') {
outputs.dir snippetsDir
useJUnitPlatform()
outputs.dir snippetsDir
useJUnitPlatform()
}

tasks.named('asciidoctor') {
inputs.dir snippetsDir
dependsOn test
inputs.dir snippetsDir
dependsOn test
}

//clean {
// delete file('src/main/generated')
//}
23 changes: 23 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
version: '3'
services:
solitour:
image: library/mysql:8.3
container_name: solitour-db
restart: always
ports:
- "3306:3306"
environment:
MYSQL_ROOT_PASSWORD: 1234
MYSQL_DATABASE: solitour
MYSQL_USER: soli
MYSQL_PASSWORD: 1234
TZ: Asia/Seoul
DB_HOST: host.docker.internal
command:
- --character-set-server=utf8mb4
- --collation-server=utf8mb4_unicode_ci
volumes:
- ./db/mysql/data:/var/lib/mysql
- ./db/mysql/config:/etc/mysql/conf.d
- ./db/mysql/init:/docker-entrypoint-initdb.d
platform: linux/x86_64
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion 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.10.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
5 changes: 4 additions & 1 deletion gradlew
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
2 changes: 2 additions & 0 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem

@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
Expand Down
12 changes: 9 additions & 3 deletions src/main/java/solitour_backend/solitour/SolitourApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.ConfigurationPropertiesScan;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.data.web.config.EnableSpringDataWebSupport;

@SpringBootApplication
@EnableJpaAuditing
@ConfigurationPropertiesScan
@EnableSpringDataWebSupport(pageSerializationMode = EnableSpringDataWebSupport.PageSerializationMode.VIA_DTO)
public class SolitourApplication {

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

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package solitour_backend.solitour.admin.controller;

import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import solitour_backend.solitour.admin.dto.UserListWithPage;
import solitour_backend.solitour.admin.service.AdminService;

@RestController
@RequiredArgsConstructor
@RequestMapping("/api/admin")
public class AdminController {

private final AdminService adminService;

@GetMapping("/user/list")
public ResponseEntity<UserListWithPage> getUserInfoList(@RequestParam(defaultValue = "1") int page,
@RequestParam(defaultValue = "") String nickname) {
UserListWithPage response = adminService.getUserInfoList(nickname, page);
return ResponseEntity.ok(response);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package solitour_backend.solitour.admin.controller;

import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import solitour_backend.solitour.admin.entity.Banner;
import solitour_backend.solitour.admin.service.BannerService;

@RestController
@RequiredArgsConstructor
@RequestMapping("/api/banner")
public class BannerController {
private final BannerService bannerService;

@RequestMapping(method = RequestMethod.POST)
public ResponseEntity createBanner(@RequestPart("imageFile") MultipartFile imageFile,
@RequestPart("directory") String directory) {
Banner banner = bannerService.createBanner(imageFile, directory);
return ResponseEntity
.status(HttpStatus.OK)
.body(banner);
}

@RequestMapping(method = RequestMethod.GET)
public ResponseEntity getBannerList() {
return bannerService.getBannerList();
}

@RequestMapping(method = RequestMethod.DELETE, value = "/{id}")
public ResponseEntity<String> deleteBanner(@PathVariable Long id) {
return bannerService.deleteBanner(id);
}

}
Loading

0 comments on commit 0ab9a5c

Please sign in to comment.