diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..a998124 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,8 @@ +## 작업 내용 +- 로그인 기능 API 구현 +- 로그인 UI 구현 +## 리뷰 받고 싶은 부분 (옵션) +- 토큰 인증 필터 로직이 괜찮은지 피드백 부탁드려요 +- UI 디자인 괜찮은지 봐주세요 +## 회고, 느낀점 (옵션) +- 성능 테스트가 어려웠어요 \ No newline at end of file diff --git a/.github/workflows/githubCD.yaml b/.github/workflows/githubCD.yaml new file mode 100644 index 0000000..e30aa67 --- /dev/null +++ b/.github/workflows/githubCD.yaml @@ -0,0 +1,99 @@ +name: Build & Delivery + +on: + push: + branches: + - 'main' + +env: + REGISTRY: ghcr.io + ORGANIZATION: lgcns-final-lgcms + REPOSITORY: ${{ github.repository }} + REGISTRY_USERNAME: ${{ github.actor }} + +jobs: + build: + runs-on: ubuntu-latest + services: + pgvector: + image: pgvector/pgvector:pg17 + env: + POSTGRES_USER: lgcms + POSTGRES_PASSWORD: 1234 + POSTGRES_DB: testdb + ports: + - 5432:5432 + valkey: + image: valkey/valkey:alpine3.22 + ports: + - 6379:6379 + kafka: + image: bitnamilegacy/kafka:4.0.0-debian-12-r10 + env: + KAFKA_CFG_NODE_ID: 0 + KAFKA_CFG_PROCESS_ROLES: controller,broker + KAFKA_CFG_LISTENERS: PLAINTEXT://:9092,CONTROLLER://:9093,EXTERNAL://:9094 + KAFKA_CFG_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092,EXTERNAL://127.0.0.1:9094 + KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP: CONTROLLER:PLAINTEXT,EXTERNAL:PLAINTEXT,PLAINTEXT:PLAINTEXT + KAFKA_CFG_CONTROLLER_QUORUM_VOTERS: 0@kafka:9093 + KAFKA_CFG_CONTROLLER_LISTENER_NAMES: CONTROLLER + KAFKA_CFG_AUTO_CREATE_TOPICS_ENABLE: true + ports: + - 9092:9092 + - 9094:9094 + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + token: ${{ secrets.TOKEN_GITHUB }} + + - name: Setup Java JDK + uses: actions/setup-java@v4 + with: + distribution: 'corretto' + java-version: 21 + + - name: Grant execute permission for gradlew + run: chmod +x ./gradlew + shell: bash + + - name: Create application-dev.yaml + run: | + mkdir -p src/main/resources + echo "${{ vars.APPLICATION_DEV }}" > src/main/resources/application-dev.yaml + + - name: Setup Gradle + uses: gradle/gradle-build-action@v2 + + - name: Build with Gradle + id: buildWithGradle + run: ./gradlew clean build + shell: bash + + - name: Extract App Name & Version + run: | + echo "APP_NAME=$(./gradlew -q getAppName | perl -pe 's/([A-Z])/-\L$1/g')" >> ${GITHUB_ENV}; + echo "APP_VERSION=$(./gradlew -q getAppVersion)" >> ${GITHUB_ENV}; + + - name: Set Docker Image version + run: | + echo "DOCKER_IMAGE=${{ env.REGISTRY }}/${{ env.ORGANIZATION }}/${{ env.APP_NAME }}:${{ env.APP_VERSION }}" >> ${GITHUB_ENV} + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ env.REGISTRY_USERNAME }} + password: ${{ secrets.TOKEN_GITHUB }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build & Push Docker Image (multi-platform) + uses: docker/build-push-action@v5 + with: + context: . + file: docker/Dockerfile + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ env.DOCKER_IMAGE }} diff --git a/.github/workflows/githubCI.yaml b/.github/workflows/githubCI.yaml new file mode 100644 index 0000000..41f4f49 --- /dev/null +++ b/.github/workflows/githubCI.yaml @@ -0,0 +1,65 @@ +name: Build & Test + +on: + push + +env: + REGISTRY: ghcr.io + ORGANIZATION: lgcns-final-lgcms + REPOSITORY: ${{ github.repository }} + REGISTRY_USERNAME: ${{ github.actor }} + +jobs: + build: + runs-on: ubuntu-latest + services: + pgvector: + image: pgvector/pgvector:pg17 + env: + POSTGRES_USER: lgcms + POSTGRES_PASSWORD: 1234 + POSTGRES_DB: testdb + ports: + - 5432:5432 + valkey: + image: valkey/valkey:alpine3.22 + ports: + - 6379:6379 + kafka: + image: bitnamilegacy/kafka:4.0.0-debian-12-r10 + env: + KAFKA_CFG_NODE_ID: 0 + KAFKA_CFG_PROCESS_ROLES: controller,broker + KAFKA_CFG_LISTENERS: PLAINTEXT://:9092,CONTROLLER://:9093,EXTERNAL://:9094 + KAFKA_CFG_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092,EXTERNAL://127.0.0.1:9094 + KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP: CONTROLLER:PLAINTEXT,EXTERNAL:PLAINTEXT,PLAINTEXT:PLAINTEXT + KAFKA_CFG_CONTROLLER_QUORUM_VOTERS: 0@kafka:9093 + KAFKA_CFG_CONTROLLER_LISTENER_NAMES: CONTROLLER + KAFKA_CFG_AUTO_CREATE_TOPICS_ENABLE: true + ports: + - 9092:9092 + - 9094:9094 + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + token: ${{ secrets.TOKEN_GITHUB }} + + - name: Setup Java JDK + uses: actions/setup-java@v4 + with: + distribution: 'corretto' + java-version: 21 + + - name: Grant execute permission for gradlew + run: chmod +x ./gradlew + shell: bash + + - name: Setup Gradle + uses: gradle/gradle-build-action@v2 + + - name: Build with Gradle + id: buildWithGradle + run: ./gradlew clean build + shell: bash + diff --git a/build.gradle b/build.gradle index 8f3c831..2f7f4fb 100644 --- a/build.gradle +++ b/build.gradle @@ -31,6 +31,8 @@ dependencies { implementation 'org.springframework.boot:spring-boot-starter-web' implementation 'org.springframework.cloud:spring-cloud-starter-circuitbreaker-resilience4j' implementation 'org.springframework.cloud:spring-cloud-starter-openfeign' + implementation 'org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE' + implementation 'net.bramp.ffmpeg:ffmpeg:0.8.0' implementation 'org.springframework.kafka:spring-kafka' compileOnly 'org.projectlombok:lombok' annotationProcessor 'org.projectlombok:lombok' @@ -48,3 +50,19 @@ dependencyManagement { tasks.named('test') { useJUnitPlatform() } + +jar { + enabled = false +} + +tasks.register("getAppName") { + doLast { + println("${rootProject.name}") + } +} + +tasks.register("getAppVersion") { + doLast { + println("${rootProject.version}") + } +} diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..f412252 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,9 @@ +FROM eclipse-temurin:21-jre-jammy +RUN apt-get update && apt-get install -y ffmpeg \ + && rm -rf /var/lib/apt/lists/* +WORKDIR /app +EXPOSE 8080 +COPY build/libs/*.jar /app/app.jar +ENTRYPOINT ["java", "-jar", "/app/app.jar"] + + diff --git a/src/main/resources/application-local.yml b/src/main/resources/application-local.yml index ee6f42c..e960f1a 100644 --- a/src/main/resources/application-local.yml +++ b/src/main/resources/application-local.yml @@ -46,3 +46,13 @@ cloud: auto: false stack: auto: false + cdn: + url: ${CND_URL} + + +ffmpeg: + path: ${FFMPEG_PATH} +ffprobe: + path: ${FFPROBE_PATH} + + diff --git a/src/main/resources/application-test.yml b/src/main/resources/application-test.yml index 16bb96e..9015839 100644 --- a/src/main/resources/application-test.yml +++ b/src/main/resources/application-test.yml @@ -5,7 +5,7 @@ spring: application: name: backend-streaming kafka: - bootstrap-servers: localhost:9092 + bootstrap-servers: localhost:9094 listener: ack-mode: manual_immediate @@ -25,4 +25,25 @@ spring: key-serializer: org.apache.kafka.common.serialization.StringSerializer value-serializer: org.springframework.kafka.support.serializer.JsonSerializer properties: - spring.json.add.type.headers: false \ No newline at end of file + spring.json.add.type.headers: false + +cloud: + aws: + s3: + bucket: hello + credentials: + access-key: akey + secret-key: skey + region: + static: ap-northeast-2 + auto: false + stack: + auto: false + cdn: + url: asdasd + + +ffmpeg: + path: asdv +ffprobe: + path: zxcas \ No newline at end of file diff --git a/src/test/java/com/lgcms/streaming/StreamingApplicationTests.java b/src/test/java/com/lgcms/streaming/StreamingApplicationTests.java index 3f111b2..d76fb89 100644 --- a/src/test/java/com/lgcms/streaming/StreamingApplicationTests.java +++ b/src/test/java/com/lgcms/streaming/StreamingApplicationTests.java @@ -2,7 +2,9 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.ActiveProfiles; +@ActiveProfiles("test") @SpringBootTest class StreamingApplicationTests {