Skip to content

Commit

Permalink
Merge pull request #21 from Fairy-Taless/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
junhaa authored May 15, 2024
2 parents 5911783 + 136fde3 commit 9602f39
Show file tree
Hide file tree
Showing 109 changed files with 4,340 additions and 0 deletions.
72 changes: 72 additions & 0 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: FairyTale Dev CI/CD

on:
push:
branches: [ "dev" ]
pull_request:
branches: [ "dev" ]
workflow_dispatch:


permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest
# JDK 설정
steps:
- name: Checkout
uses: actions/checkout@v3

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

# gradle build 시간 향상
- 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-
# application.yml 파일 생성
- name: make application.yml
run: |
mkdir -p src/main/resources
echo "$APPLICATION" > src/main/resources/application.yml
env:
APPLICATION: ${{ secrets.APPLICATION }}

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

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

- name: Docker build
run: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker build -t app .
docker tag app ${{ secrets.DOCKER_USERNAME }}/fairytale:latest
docker push ${{ secrets.DOCKER_USERNAME }}/fairytale:latest
- name: Deploy to dev
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ubuntu
key: ${{ secrets.PRIVATE_KEY }}
script: |
sudo docker pull ${{ secrets.DOCKER_USERNAME }}/fairytale:latest
sudo docker stop $(docker ps -a -q)
sudo docker run -d --log-driver=syslog -p 8080:8080 -e SPRING_PROFILES_ACTIVE= ${{ secrets.DOCKER_USERNAME }}/fairytale:latest
sudo docker rm $(docker ps --filter 'status=exited' -a -q)
sudo docker image prune -a -f
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM openjdk:17
COPY ./build/libs/TBD-0.0.1-SNAPSHOT.jar fairytale.jar
ENTRYPOINT ["java", "-jar", "fairytale.jar"]
49 changes: 49 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ java {
sourceCompatibility = '17'
}

// build 이름 변경
jar{
archiveBaseName = 'fairytale'
version = '0.0.1-SNAPSHOT'
enabled = false
}

configurations {
compileOnly {
extendsFrom annotationProcessor
Expand All @@ -25,10 +32,52 @@ 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'

//logging
implementation 'org.springframework.boot:spring-boot-starter-log4j2'
modules {
module("org.springframework.boot:spring-boot-starter-logging") {
replacedBy("org.springframework.boot:spring-boot-starter-log4j2")
}
}

// ElevenLabs API
implementation ('net.andrewcpu:elevenlabs-api:2.7.8')

// AWS
implementation 'org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE'

compileOnly 'org.projectlombok:lombok'
runtimeOnly 'com.mysql:mysql-connector-j'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'

// Face Swap API
implementation 'com.squareup.okhttp3:okhttp:3.10.0'
implementation 'org.json:json:20200518'

// Face Swap API
implementation 'com.squareup.okhttp3:okhttp:3.10.0'
implementation 'org.json:json:20200518'

// Face Swap API
implementation 'com.squareup.okhttp3:okhttp:3.10.0'
implementation 'org.json:json:20200518'

// webhook
implementation 'javax.xml.bind:jaxb-api:2.3.1'

// Spring Security OAUTH 2.1
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.security:spring-security-oauth2-client'

// JWT token
implementation 'io.jsonwebtoken:jjwt:0.12.3'

compileOnly 'org.projectlombok:lombok'
runtimeOnly 'com.mysql:mysql-connector-j'
annotationProcessor 'org.projectlombok:lombok'
implementation 'org.springframework.boot:spring-boot-starter-test'
}

tasks.named('test') {
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/fairytale/tbd/FairytaleApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

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

@SpringBootApplication
@EnableJpaAuditing
public class FairytaleApplication {

public static void main(String[] args) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package fairytale.tbd.domain.faceSwap.converter;

import java.time.LocalDateTime;

import fairytale.tbd.domain.faceSwap.entity.OriginalCharacter;
import fairytale.tbd.domain.faceSwap.web.dto.FaceResponseDTO;

public class FaceSwapConverter {

public static FaceResponseDTO.OriginalCharacterSaveResponseDTO toOriginalCharacterSaveResponseDTO(
OriginalCharacter originalCharacter) {
return FaceResponseDTO.OriginalCharacterSaveResponseDTO.builder()
.created_at(LocalDateTime.now())
.image_url(originalCharacter.getOriginalURL())
.original_character_id(originalCharacter.getOriginId())
.build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package fairytale.tbd.domain.faceSwap.entity;

import fairytale.tbd.domain.fairytale.entity.Fairytale;
import fairytale.tbd.domain.user.entity.User;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Entity
@Getter
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "custom_character")
public class CustomCharacter {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "custom_character_id")
private Long customId;

@Column(name = "custom_character_image_url", nullable = false)
private String customURL;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "user_id")
private User user;

@Column(name = "page_num", nullable = false)
private Long pageNum;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "fairytale_id")
private Fairytale fairytale;

public void setUser(User user) {
this.user = user;
}

public void setFairytale(Fairytale fairytale) {
this.fairytale = fairytale;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package fairytale.tbd.domain.faceSwap.entity;

import fairytale.tbd.global.entity.BaseEntity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Entity
@Getter
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "image_save_queue")
public class ImageSaveQueue extends BaseEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "image_save_id")
private Long id;

@Column(name = "user_id", nullable = false)
private Long userId;

@Column(name = "image_url", nullable = false)
private String imageURL;

@Column(name = "page_num", nullable = false)
private Long pageNum;

@Column(name = "fairytale_id", nullable = false)
private Long fairytaleId;

@Column(name = "image_swap_request_id", nullable = false)
private String requestId;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package fairytale.tbd.domain.faceSwap.entity;

import fairytale.tbd.domain.fairytale.entity.Fairytale;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Entity
@Getter
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "original_character")
public class OriginalCharacter {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "original_character_id")
private Long originId;

@Column(name = "originl_character_image_url", nullable = false)
private String originalURL;

@Column(name = "page_num", nullable = false)
private Long pageNum;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "fairytale_id")
private Fairytale fairytale;

@Column(name = "original_character_image_opts", nullable = false)
private String opts;

// 연관 관계 편의 메서드

public void setFairytale(Fairytale fairytale) {
this.fairytale = fairytale;
}

}
18 changes: 18 additions & 0 deletions src/main/java/fairytale/tbd/domain/faceSwap/entity/Uuid.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package fairytale.tbd.domain.faceSwap.entity;

import jakarta.persistence.*;
import lombok.*;
@Entity
@Getter
@Builder
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor(access = AccessLevel.PROTECTED)

public class Uuid {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long uuidId;

@Column(unique = true)
private String uuid;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package fairytale.tbd.domain.faceSwap.exception;

import fairytale.tbd.global.enums.statuscode.BaseCode;
import fairytale.tbd.global.exception.GeneralException;

public class FaceNotDetectException extends GeneralException {
public FaceNotDetectException(BaseCode errorStatus) {
super(errorStatus);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package fairytale.tbd.domain.faceSwap.exception;

import fairytale.tbd.global.enums.statuscode.BaseCode;
import fairytale.tbd.global.exception.GeneralException;

public class FaceSwapFailureException extends GeneralException {
public FaceSwapFailureException(BaseCode errorStatus) {
super(errorStatus);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package fairytale.tbd.domain.faceSwap.exception;

import fairytale.tbd.global.enums.statuscode.BaseCode;
import fairytale.tbd.global.exception.GeneralException;

public class UserFaceNotExistException extends GeneralException {
public UserFaceNotExistException(BaseCode errorStatus) {
super(errorStatus);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package fairytale.tbd.domain.faceSwap.repository;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import fairytale.tbd.domain.faceSwap.entity.CustomCharacter;

@Repository
public interface CustomCharacterRepository extends JpaRepository<CustomCharacter, Long> {
List<CustomCharacter> findByUserIdAndFairytaleId(Long userId, Long fairytaleId);
}
Loading

0 comments on commit 9602f39

Please sign in to comment.