diff --git a/.github/workflows/server-cd-spring.yml b/.github/workflows/server-cd-spring.yml new file mode 100644 index 0000000..2727e7e --- /dev/null +++ b/.github/workflows/server-cd-spring.yml @@ -0,0 +1,96 @@ +name: Server Spring CD + +on: + pull_request: + branches: ["develop", "main"] + paths: + - "server/spring/**" + types: + - closed + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: "17" + distribution: "adopt" + + - name: Run chmod to make gradlew executable + run: | + cd server/spring + chmod +x ./gradlew + + - name: Build with Gradle + run: | + cd server/spring + ./gradlew clean build + + - name: Create application.yml + env: + DB_HOST_IP: ${{ secrets.SERVER_ENV_DB_HOST_IP }} + DB_PORT: ${{ secrets.SERVER_ENV_DB_PORT }} + DB_USER_NAME: ${{ secrets.SERVER_ENV_DB_USER_NAME }} + DB_PASSWORD: ${{ secrets.SERVER_ENV_DB_PASSWORD }} + DB_DATABASE_NAME: ${{ secrets.SERVER_ENV_DB_DATABASE_NAME }} + ACCESS_ID: ${{ secrets.SERVER_ENV_ACCESS_ID }} + SECRET_ACCESS_KEY: ${{ secrets.SERVER_ENV_SECRET_ACCESS_KEY }} + JWT_SECRET_KEY: ${{ secrets.SERVER_ENV_JWT_SECRET_KEY }} + GREEN_EYE_SECRET_KEY: ${{secrets.GREEN_EYE_SECRET_KEY}} + GREEN_EYE_REQUEST_URL: ${{secrets.GREEN_EYE_REQUEST_URL}} + CLOUD_FUNCTIONS_EXECUTE_URL: ${{secrets.CLOUD_FUNCTIONS_EXECUTE_URL}} + CLOUD_FUNCTIONS_REQUEST_URL: ${{secrets.CLOUD_FUNCTIONS_REQUEST_URL}} + API_GW_ACCESS_KEY: ${{secrets.API_GW_ACCESS_KEY}} + REFRESH_SECRET_KEY: ${{secrets.REFRESH_SECRET_KEY}} + REDIS_HOST_IP: ${{secrets.REDIS_HOST_IP}} + REDIS_PASSWORD: ${{secrets.REDIS_PASSWORD}} + REDIS_PORT: ${{secrets.REDIS_PORT}} + REDIS_TTL: ${{secrets.REDIS_TTL}} + run: | + cd server + touch ./application.yml + echo "DB_HOST_IP=$DB_HOST_IP" >> application.yml + echo "DB_PORT=$DB_PORT" >> application.yml + echo "DB_USER_NAME=$DB_USER_NAME" >> application.yml + echo "DB_PASSWORD=$DB_PASSWORD" >> application.yml + echo "DB_DATABASE_NAME=$DB_DATABASE_NAME" >> application.yml + echo "ACCESS_ID=$ACCESS_ID" >> application.yml + echo "SECRET_ACCESS_KEY=$SECRET_ACCESS_KEY" >> application.yml + echo "JWT_SECRET_KEY=$JWT_SECRET_KEY" >> application.yml + echo "GREEN_EYE_SECRET_KEY=$GREEN_EYE_SECRET_KEY" >> application.yml + echo "GREEN_EYE_REQUEST_URL=$GREEN_EYE_REQUEST_URL" >> application.yml + echo "CLOUD_FUNCTIONS_EXECUTE_URL=$CLOUD_FUNCTIONS_EXECUTE_URL" >> application.yml + echo "CLOUD_FUNCTIONS_REQUEST_URL=$CLOUD_FUNCTIONS_REQUEST_URL" >> application.yml + echo "API_GW_ACCESS_KEY=$API_GW_ACCESS_KEY" >> application.yml + echo "REFRESH_SECRET_KEY=$REFRESH_SECRET_KEY" >> application.yml + echo "REDIS_HOST_IP=$REDIS_HOST_IP" >> application.yml + echo "REDIS_PASSWORD=$REDIS_PASSWORD" >> application.yml + echo "REDIS_PORT=$REDIS_PORT" >> application.yml + echo "REDIS_TTL=$REDIS_TTL" >> application.yml + + - name: Build Docker image + run: docker build --platform linux/amd64 ./server -t ${{ secrets.NCP_SPRING_REGISTRY }}/catchy-tape-sub:latest -f ./server/Dockerfile.spring + + - name: Login NCP container registry + run: docker login ${{ secrets.NCP_SPRING_REGISTRY }} -u ${{ secrets.NCP_DOCKER_ACCESS_KEY_ID }} -p ${{ secrets.NCP_DOCKER_SECRET_KEY }} + + - name: Push Docker image to registry + run: docker push ${{ secrets.NCP_SPRING_REGISTRY }}/catchy-tape-sub:latest + + - name: SSH into Server + uses: appleboy/ssh-action@master + with: + host: ${{ secrets.SERVER_SSH_HOST }} + username: ${{ secrets.SERVER_SSH_USER }} + password: ${{ secrets.SERVER_SSH_PASSWORD }} + port: ${{ secrets.SERVER_SSH_PORT }} + script: | + export NCP_SPRING_REGISTRY=${{ secrets.NCP_SPRING_REGISTRY }} + export NCP_DOCKER_ACCESS_KEY_ID=${{ secrets.NCP_DOCKER_ACCESS_KEY_ID }} + export NCP_DOCKER_SECRET_KEY=${{ secrets.NCP_DOCKER_SECRET_KEY }} + sh server/deploy-spring.sh + curl -X POST -H 'Content-type: application/json' --data '{"text":"스프링 서버 배포 성공!"}' ${{ secrets.SLACK_WEBHOOK_URL }} diff --git a/.github/workflows/server-cd.yml b/.github/workflows/server-cd.yml index 372a5e0..442e31d 100644 --- a/.github/workflows/server-cd.yml +++ b/.github/workflows/server-cd.yml @@ -1,10 +1,10 @@ -name: Server CD +name: Server Nest CD on: pull_request: branches: ["develop", "main"] paths: - - "server/**" + - "server/nest/**" types: - closed @@ -75,7 +75,7 @@ jobs: echo "REDIS_TTL=$REDIS_TTL" >> prod.env - name: Build Docker image - run: docker build --platform linux/amd64 ./server -t ${{ secrets.NCP_REGISTRY }}/catchy-tape:latest + run: docker build --platform linux/amd64 ./server -t ${{ secrets.NCP_REGISTRY }}/catchy-tape:latest -f ./server/Dockerfile.nest - name: Login NCP container registry run: docker login ${{ secrets.NCP_REGISTRY }} -u ${{ secrets.NCP_DOCKER_ACCESS_KEY_ID }} -p ${{ secrets.NCP_DOCKER_SECRET_KEY }} diff --git a/.github/workflows/server-ci-spring.yml b/.github/workflows/server-ci-spring.yml new file mode 100644 index 0000000..aaf6fc4 --- /dev/null +++ b/.github/workflows/server-ci-spring.yml @@ -0,0 +1,72 @@ +name: Backend Spring CI + +on: + pull_request: + branches: [develop] + paths: + - "server/spring/**" + +defaults: + run: + working-directory: ./server/spring + +jobs: + BACKEND-SPRING-CI: + runs-on: ubuntu-20.04 + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: 17 + distribution: "adopt" + + - name: Create application.yml + env: + DB_HOST_IP: ${{ secrets.SERVER_ENV_DB_HOST_IP }} + DB_PORT: ${{ secrets.SERVER_ENV_DB_PORT }} + DB_USER_NAME: ${{ secrets.SERVER_ENV_DB_USER_NAME }} + DB_PASSWORD: ${{ secrets.SERVER_ENV_DB_PASSWORD }} + DB_DATABASE_NAME: ${{ secrets.SERVER_ENV_DB_DATABASE_NAME }} + ACCESS_ID: ${{ secrets.SERVER_ENV_ACCESS_ID }} + SECRET_ACCESS_KEY: ${{ secrets.SERVER_ENV_SECRET_ACCESS_KEY }} + JWT_SECRET_KEY: ${{ secrets.SERVER_ENV_JWT_SECRET_KEY }} + GREEN_EYE_SECRET_KEY: ${{secrets.GREEN_EYE_SECRET_KEY}} + GREEN_EYE_REQUEST_URL: ${{secrets.GREEN_EYE_REQUEST_URL}} + CLOUD_FUNCTIONS_EXECUTE_URL: ${{secrets.CLOUD_FUNCTIONS_EXECUTE_URL}} + CLOUD_FUNCTIONS_REQUEST_URL: ${{secrets.CLOUD_FUNCTIONS_REQUEST_URL}} + API_GW_ACCESS_KEY: ${{secrets.API_GW_ACCESS_KEY}} + REFRESH_SECRET_KEY: ${{secrets.REFRESH_SECRET_KEY}} + REDIS_HOST_IP: ${{secrets.REDIS_HOST_IP}} + REDIS_PASSWORD: ${{secrets.REDIS_PASSWORD}} + REDIS_PORT: ${{secrets.REDIS_PORT}} + REDIS_TTL: ${{secrets.REDIS_TTL}} + run: | + touch application.yml + echo "DB_HOST_IP=$DB_HOST_IP" >> application.yml + echo "DB_PORT=$DB_PORT" >> application.yml + echo "DB_USER_NAME=$DB_USER_NAME" >> application.yml + echo "DB_PASSWORD=$DB_PASSWORD" >> application.yml + echo "DB_DATABASE_NAME=$DB_DATABASE_NAME" >> application.yml + echo "ACCESS_ID=$ACCESS_ID" >> application.yml + echo "SECRET_ACCESS_KEY=$SECRET_ACCESS_KEY" >> application.yml + echo "JWT_SECRET_KEY=$JWT_SECRET_KEY" >> application.yml + echo "GREEN_EYE_SECRET_KEY=$GREEN_EYE_SECRET_KEY" >> application.yml + echo "GREEN_EYE_REQUEST_URL=$GREEN_EYE_REQUEST_URL" >> application.yml + echo "CLOUD_FUNCTIONS_EXECUTE_URL=$CLOUD_FUNCTIONS_EXECUTE_URL" >> application.yml + echo "CLOUD_FUNCTIONS_REQUEST_URL=$CLOUD_FUNCTIONS_REQUEST_URL" >> application.yml + echo "API_GW_ACCESS_KEY=$API_GW_ACCESS_KEY" >> application.yml + echo "REFRESH_SECRET_KEY=$REFRESH_SECRET_KEY" >> application.yml + echo "REDIS_HOST_IP=$REDIS_HOST_IP" >> application.yml + echo "REDIS_PASSWORD=$REDIS_PASSWORD" >> application.yml + echo "REDIS_PORT=$REDIS_PORT" >> application.yml + echo "REDIS_TTL=$REDIS_TTL" >> application.yml + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: Test with Gradle + run: ./gradlew --info test diff --git a/.github/workflows/server-dev-ci.yml b/.github/workflows/server-ci.yml similarity index 97% rename from .github/workflows/server-dev-ci.yml rename to .github/workflows/server-ci.yml index ea71da1..b91c3e8 100644 --- a/.github/workflows/server-dev-ci.yml +++ b/.github/workflows/server-ci.yml @@ -1,14 +1,14 @@ -name: Backend Dev CI +name: Backend Nest CI on: pull_request: branches: [develop] paths: - - "server/**" + - "server/nest/**" defaults: run: - working-directory: ./server + working-directory: ./server/nest jobs: BACKEND-CI: diff --git a/server/.dockerignore b/server/.dockerignore index 56b80bd..d9b6db1 100644 --- a/server/.dockerignore +++ b/server/.dockerignore @@ -1,4 +1,5 @@ .git -Dockerfile -node_modules -dist \ No newline at end of file +Dockerfile.nest +Dockerfile.spring +nest/node_modules +nest/dist \ No newline at end of file diff --git a/server/.gitignore b/server/.gitignore index 26934fd..93c1eac 100644 --- a/server/.gitignore +++ b/server/.gitignore @@ -1,9 +1,9 @@ # compiled output -/dist -/node_modules +/nest/dist +/nest/node_modules # Logs -logs +/nest/logs *.log npm-debug.log* pnpm-debug.log* diff --git a/server/Dockerfile b/server/Dockerfile.nest similarity index 91% rename from server/Dockerfile rename to server/Dockerfile.nest index c4c38a5..07e6e85 100644 --- a/server/Dockerfile +++ b/server/Dockerfile.nest @@ -4,7 +4,7 @@ ENV TZ=Asia/Seoul WORKDIR /catchy-tape -COPY . . +COPY nest . RUN npm install RUN npm run build diff --git a/server/Dockerfile.spring b/server/Dockerfile.spring new file mode 100644 index 0000000..4a8f094 --- /dev/null +++ b/server/Dockerfile.spring @@ -0,0 +1,17 @@ +FROM openjdk:17-alpine + +ENV TZ=Asia/Seoul + +WORKDIR /catchy-tape-spring + +# 인자 설정 - JAR_File +ARG JAR_FILE=spring/build/libs/*.jar + +# jar 파일 복제 +COPY ${JAR_FILE} app.jar + +# 해당 포트를 외부로 개방 +EXPOSE 8080 + +# 실행 명령어 +ENTRYPOINT ["java", "-jar", "app.jar"] \ No newline at end of file diff --git a/server/deploy-spring.sh b/server/deploy-spring.sh new file mode 100644 index 0000000..dca2d14 --- /dev/null +++ b/server/deploy-spring.sh @@ -0,0 +1,48 @@ +#!/bin/sh + + +# blue 컨테이너가 띄워져 있는지 확인 (8080 포트 == blue) +EXIST_BLUE=$(netstat -lntp | grep 8080) + +if [ -n "$EXIST_BLUE" ]; then + TARGET_COLOR="green" + NOW_COLOR="blue" + WEB_SERVER_TARGET_PORT=8081 + WEB_SERVER_STOP_PORT=8080 + TARGET_SERVER_NAME="catchy-tape-sub-green" + NOW_SERVER_NAME="catchy-tape-sub-blue" +else + TARGET_COLOR="blue" + NOW_COLOR="green" + WEB_SERVER_TARGET_PORT=8080 + WEB_SERVER_STOP_PORT=8081 + TARGET_SERVER_NAME="catchy-tape-sub-blue" + NOW_SERVER_NAME="catchy-tape-sub-green" +fi + +# 1 새로운 서버를 띄운다 +docker login $NCP_SPRING_REGISTRY -u $NCP_DOCKER_ACCESS_KEY_ID -p $NCP_DOCKER_SECRET_KEY +docker pull $NCP_SPRING_REGISTRY/catchy-tape-sub:latest +docker run -v /home/hyung/logs:/catchy-tape-sub/logs -d -p $WEB_SERVER_TARGET_PORT:8080 --name $TARGET_SERVER_NAME $NCP_SPRING_REGISTRY/catchy-tape-sub:latest + +# 2 nginx 포트 설정 변경 후 reload +NGINX_CONFIG="/etc/nginx/nginx.conf" +sed -i "s/$WEB_SERVER_STOP_PORT/$WEB_SERVER_TARGET_PORT/" $NGINX_CONFIG +nginx -s reload + +# 3 원래 서버 종료 & 삭제 +FIRST_DEPLOYED_SERVER="catchy-tape-sub" +FIRST_DEPLOYED_SERVER_ID=$(docker ps --filter "name=$FIRST_DEPLOYED_SERVER" -q) +if [ -n "$FIRST_DEPLOYED_SERVER_ID" ]; then + docker stop $FIRST_DEPLOYED_SERVER + docker rm $FIRST_DEPLOYED_SERVER +fi + +STOP_SERVER_ID=$(docker ps --filter "name=$NOW_SERVER_NAME" -q) +if [ -n "$STOP_SERVER_ID" ]; then + docker stop $STOP_SERVER_ID + docker rm $NOW_SERVER_NAME +fi + +# 사용하지 않는 도커 이미지 정리 +docker image prune -a -f \ No newline at end of file diff --git a/server/.eslintrc.js b/server/nest/.eslintrc.js similarity index 100% rename from server/.eslintrc.js rename to server/nest/.eslintrc.js diff --git a/server/.prettierrc b/server/nest/.prettierrc similarity index 100% rename from server/.prettierrc rename to server/nest/.prettierrc diff --git a/server/nest-cli.json b/server/nest/nest-cli.json similarity index 100% rename from server/nest-cli.json rename to server/nest/nest-cli.json diff --git a/server/package-lock.json b/server/nest/package-lock.json similarity index 100% rename from server/package-lock.json rename to server/nest/package-lock.json diff --git a/server/package.json b/server/nest/package.json similarity index 100% rename from server/package.json rename to server/nest/package.json diff --git a/server/src/app.controller.spec.ts b/server/nest/src/app.controller.spec.ts similarity index 100% rename from server/src/app.controller.spec.ts rename to server/nest/src/app.controller.spec.ts diff --git a/server/src/app.controller.ts b/server/nest/src/app.controller.ts similarity index 100% rename from server/src/app.controller.ts rename to server/nest/src/app.controller.ts diff --git a/server/src/app.module.ts b/server/nest/src/app.module.ts similarity index 100% rename from server/src/app.module.ts rename to server/nest/src/app.module.ts diff --git a/server/src/app.service.ts b/server/nest/src/app.service.ts similarity index 100% rename from server/src/app.service.ts rename to server/nest/src/app.service.ts diff --git a/server/src/auth/auth.controller.spec.ts b/server/nest/src/auth/auth.controller.spec.ts similarity index 100% rename from server/src/auth/auth.controller.spec.ts rename to server/nest/src/auth/auth.controller.spec.ts diff --git a/server/src/auth/auth.controller.ts b/server/nest/src/auth/auth.controller.ts similarity index 100% rename from server/src/auth/auth.controller.ts rename to server/nest/src/auth/auth.controller.ts diff --git a/server/src/auth/auth.module.ts b/server/nest/src/auth/auth.module.ts similarity index 100% rename from server/src/auth/auth.module.ts rename to server/nest/src/auth/auth.module.ts diff --git a/server/src/auth/auth.service.spec.ts b/server/nest/src/auth/auth.service.spec.ts similarity index 100% rename from server/src/auth/auth.service.spec.ts rename to server/nest/src/auth/auth.service.spec.ts diff --git a/server/src/auth/auth.service.ts b/server/nest/src/auth/auth.service.ts similarity index 100% rename from server/src/auth/auth.service.ts rename to server/nest/src/auth/auth.service.ts diff --git a/server/src/auth/jwt.strategy.ts b/server/nest/src/auth/jwt.strategy.ts similarity index 100% rename from server/src/auth/jwt.strategy.ts rename to server/nest/src/auth/jwt.strategy.ts diff --git a/server/src/codes/errorCode.enum.ts b/server/nest/src/codes/errorCode.enum.ts similarity index 100% rename from server/src/codes/errorCode.enum.ts rename to server/nest/src/codes/errorCode.enum.ts diff --git a/server/src/codes/httpStatusCode.enum.ts b/server/nest/src/codes/httpStatusCode.enum.ts similarity index 100% rename from server/src/codes/httpStatusCode.enum.ts rename to server/nest/src/codes/httpStatusCode.enum.ts diff --git a/server/src/config/catchyException.ts b/server/nest/src/config/catchyException.ts similarity index 100% rename from server/src/config/catchyException.ts rename to server/nest/src/config/catchyException.ts diff --git a/server/src/config/decorators.ts b/server/nest/src/config/decorators.ts similarity index 100% rename from server/src/config/decorators.ts rename to server/nest/src/config/decorators.ts diff --git a/server/src/config/greenEye.config.ts b/server/nest/src/config/greenEye.config.ts similarity index 100% rename from server/src/config/greenEye.config.ts rename to server/nest/src/config/greenEye.config.ts diff --git a/server/src/config/logger.config.ts b/server/nest/src/config/logger.config.ts similarity index 100% rename from server/src/config/logger.config.ts rename to server/nest/src/config/logger.config.ts diff --git a/server/src/config/ncloud.config.ts b/server/nest/src/config/ncloud.config.ts similarity index 100% rename from server/src/config/ncloud.config.ts rename to server/nest/src/config/ncloud.config.ts diff --git a/server/src/config/typeorm.config.ts b/server/nest/src/config/typeorm.config.ts similarity index 100% rename from server/src/config/typeorm.config.ts rename to server/nest/src/config/typeorm.config.ts diff --git a/server/src/constants.ts b/server/nest/src/constants.ts similarity index 100% rename from server/src/constants.ts rename to server/nest/src/constants.ts diff --git a/server/src/dto/cloudFunctions.response.dto.ts b/server/nest/src/dto/cloudFunctions.response.dto.ts similarity index 100% rename from server/src/dto/cloudFunctions.response.dto.ts rename to server/nest/src/dto/cloudFunctions.response.dto.ts diff --git a/server/src/dto/greenEye.response.dto.ts b/server/nest/src/dto/greenEye.response.dto.ts similarity index 100% rename from server/src/dto/greenEye.response.dto.ts rename to server/nest/src/dto/greenEye.response.dto.ts diff --git a/server/src/dto/musicCreate.dto.ts b/server/nest/src/dto/musicCreate.dto.ts similarity index 100% rename from server/src/dto/musicCreate.dto.ts rename to server/nest/src/dto/musicCreate.dto.ts diff --git a/server/src/dto/playlistCreate.dto.ts b/server/nest/src/dto/playlistCreate.dto.ts similarity index 100% rename from server/src/dto/playlistCreate.dto.ts rename to server/nest/src/dto/playlistCreate.dto.ts diff --git a/server/src/dto/playlistInfo.dto.ts b/server/nest/src/dto/playlistInfo.dto.ts similarity index 100% rename from server/src/dto/playlistInfo.dto.ts rename to server/nest/src/dto/playlistInfo.dto.ts diff --git a/server/src/dto/userCreate.dto.ts b/server/nest/src/dto/userCreate.dto.ts similarity index 100% rename from server/src/dto/userCreate.dto.ts rename to server/nest/src/dto/userCreate.dto.ts diff --git a/server/src/dto/userUpdate.dto.ts b/server/nest/src/dto/userUpdate.dto.ts similarity index 100% rename from server/src/dto/userUpdate.dto.ts rename to server/nest/src/dto/userUpdate.dto.ts diff --git a/server/src/entity/music.entity.ts b/server/nest/src/entity/music.entity.ts similarity index 100% rename from server/src/entity/music.entity.ts rename to server/nest/src/entity/music.entity.ts diff --git a/server/src/entity/music_playlist.entity.ts b/server/nest/src/entity/music_playlist.entity.ts similarity index 100% rename from server/src/entity/music_playlist.entity.ts rename to server/nest/src/entity/music_playlist.entity.ts diff --git a/server/src/entity/playlist.entity.ts b/server/nest/src/entity/playlist.entity.ts similarity index 100% rename from server/src/entity/playlist.entity.ts rename to server/nest/src/entity/playlist.entity.ts diff --git a/server/src/entity/recent_played.entity.ts b/server/nest/src/entity/recent_played.entity.ts similarity index 100% rename from server/src/entity/recent_played.entity.ts rename to server/nest/src/entity/recent_played.entity.ts diff --git a/server/src/entity/user.entity.ts b/server/nest/src/entity/user.entity.ts similarity index 100% rename from server/src/entity/user.entity.ts rename to server/nest/src/entity/user.entity.ts diff --git a/server/src/main.ts b/server/nest/src/main.ts similarity index 100% rename from server/src/main.ts rename to server/nest/src/main.ts diff --git a/server/src/music/music.controller.spec.ts b/server/nest/src/music/music.controller.spec.ts similarity index 100% rename from server/src/music/music.controller.spec.ts rename to server/nest/src/music/music.controller.spec.ts diff --git a/server/src/music/music.controller.ts b/server/nest/src/music/music.controller.ts similarity index 100% rename from server/src/music/music.controller.ts rename to server/nest/src/music/music.controller.ts diff --git a/server/src/music/music.module.ts b/server/nest/src/music/music.module.ts similarity index 100% rename from server/src/music/music.module.ts rename to server/nest/src/music/music.module.ts diff --git a/server/src/music/music.service.spec.ts b/server/nest/src/music/music.service.spec.ts similarity index 100% rename from server/src/music/music.service.spec.ts rename to server/nest/src/music/music.service.spec.ts diff --git a/server/src/music/music.service.ts b/server/nest/src/music/music.service.ts similarity index 100% rename from server/src/music/music.service.ts rename to server/nest/src/music/music.service.ts diff --git a/server/src/playlist/playlist.controller.ts b/server/nest/src/playlist/playlist.controller.ts similarity index 100% rename from server/src/playlist/playlist.controller.ts rename to server/nest/src/playlist/playlist.controller.ts diff --git a/server/src/playlist/playlist.module.ts b/server/nest/src/playlist/playlist.module.ts similarity index 100% rename from server/src/playlist/playlist.module.ts rename to server/nest/src/playlist/playlist.module.ts diff --git a/server/src/playlist/playlist.service.ts b/server/nest/src/playlist/playlist.service.ts similarity index 100% rename from server/src/playlist/playlist.service.ts rename to server/nest/src/playlist/playlist.service.ts diff --git a/server/src/repository/music.repository.ts b/server/nest/src/repository/music.repository.ts similarity index 100% rename from server/src/repository/music.repository.ts rename to server/nest/src/repository/music.repository.ts diff --git a/server/src/repository/music_playlist.repository.ts b/server/nest/src/repository/music_playlist.repository.ts similarity index 100% rename from server/src/repository/music_playlist.repository.ts rename to server/nest/src/repository/music_playlist.repository.ts diff --git a/server/src/repository/playlist.repository.ts b/server/nest/src/repository/playlist.repository.ts similarity index 100% rename from server/src/repository/playlist.repository.ts rename to server/nest/src/repository/playlist.repository.ts diff --git a/server/src/repository/recent_played.repository.ts b/server/nest/src/repository/recent_played.repository.ts similarity index 100% rename from server/src/repository/recent_played.repository.ts rename to server/nest/src/repository/recent_played.repository.ts diff --git a/server/src/repository/user.repository.ts b/server/nest/src/repository/user.repository.ts similarity index 100% rename from server/src/repository/user.repository.ts rename to server/nest/src/repository/user.repository.ts diff --git a/server/src/upload/upload.controller.ts b/server/nest/src/upload/upload.controller.ts similarity index 100% rename from server/src/upload/upload.controller.ts rename to server/nest/src/upload/upload.controller.ts diff --git a/server/src/upload/upload.module.ts b/server/nest/src/upload/upload.module.ts similarity index 100% rename from server/src/upload/upload.module.ts rename to server/nest/src/upload/upload.module.ts diff --git a/server/src/upload/upload.service.ts b/server/nest/src/upload/upload.service.ts similarity index 98% rename from server/src/upload/upload.service.ts rename to server/nest/src/upload/upload.service.ts index 186ce8d..decc354 100644 --- a/server/src/upload/upload.service.ts +++ b/server/nest/src/upload/upload.service.ts @@ -2,9 +2,9 @@ import axios from 'axios'; import * as fs from 'fs'; import { Injectable, Logger } from '@nestjs/common'; import { HTTP_STATUS_CODE } from 'src/codes/httpStatusCode.enum'; -import { NcloudConfigService } from './../config/ncloud.config'; +import { NcloudConfigService } from '../config/ncloud.config'; import { S3 } from 'aws-sdk'; -import { contentTypeHandler, keyFlags } from './../constants'; +import { contentTypeHandler, keyFlags } from '../constants'; import { CatchyException } from 'src/config/catchyException'; import { ERROR_CODE } from 'src/codes/errorCode.enum'; import { Readable } from 'stream'; diff --git a/server/src/user/user.controller.spec.ts b/server/nest/src/user/user.controller.spec.ts similarity index 100% rename from server/src/user/user.controller.spec.ts rename to server/nest/src/user/user.controller.spec.ts diff --git a/server/src/user/user.controller.ts b/server/nest/src/user/user.controller.ts similarity index 100% rename from server/src/user/user.controller.ts rename to server/nest/src/user/user.controller.ts diff --git a/server/src/user/user.module.ts b/server/nest/src/user/user.module.ts similarity index 100% rename from server/src/user/user.module.ts rename to server/nest/src/user/user.module.ts diff --git a/server/src/user/user.service.spec.ts b/server/nest/src/user/user.service.spec.ts similarity index 100% rename from server/src/user/user.service.spec.ts rename to server/nest/src/user/user.service.spec.ts diff --git a/server/src/user/user.service.ts b/server/nest/src/user/user.service.ts similarity index 99% rename from server/src/user/user.service.ts rename to server/nest/src/user/user.service.ts index 70c4e53..d6c13e0 100644 --- a/server/src/user/user.service.ts +++ b/server/nest/src/user/user.service.ts @@ -7,7 +7,7 @@ import { InjectRepository } from '@nestjs/typeorm'; import { CatchyException } from 'src/config/catchyException'; import { ERROR_CODE } from 'src/codes/errorCode.enum'; import { Recent_Played } from 'src/entity/recent_played.entity'; -import { UserUpdateDto } from './../dto/userUpdate.dto'; +import { UserUpdateDto } from '../dto/userUpdate.dto'; import { MusicRepository } from 'src/repository/music.repository'; import { UserRepository } from '../repository/user.repository'; import { Recent_PlayedRepository } from 'src/repository/recent_played.repository'; diff --git a/server/test/app.e2e-spec.ts b/server/nest/test/app.e2e-spec.ts similarity index 100% rename from server/test/app.e2e-spec.ts rename to server/nest/test/app.e2e-spec.ts diff --git a/server/test/constants/music.mockData.ts b/server/nest/test/constants/music.mockData.ts similarity index 100% rename from server/test/constants/music.mockData.ts rename to server/nest/test/constants/music.mockData.ts diff --git a/server/test/jest-e2e.json b/server/nest/test/jest-e2e.json similarity index 100% rename from server/test/jest-e2e.json rename to server/nest/test/jest-e2e.json diff --git a/server/test/utils/lovelovelove.mp3 b/server/nest/test/utils/lovelovelove.mp3 similarity index 100% rename from server/test/utils/lovelovelove.mp3 rename to server/nest/test/utils/lovelovelove.mp3 diff --git "a/server/test/utils/\355\225\230\355\225\230.png" "b/server/nest/test/utils/\355\225\230\355\225\230.png" similarity index 100% rename from "server/test/utils/\355\225\230\355\225\230.png" rename to "server/nest/test/utils/\355\225\230\355\225\230.png" diff --git a/server/nest/tsconfig.build.json b/server/nest/tsconfig.build.json new file mode 100644 index 0000000..64f86c6 --- /dev/null +++ b/server/nest/tsconfig.build.json @@ -0,0 +1,4 @@ +{ + "extends": "./tsconfig.json", + "exclude": ["node_modules", "test", "dist", "**/*spec.ts"] +} diff --git a/server/tsconfig.json b/server/nest/tsconfig.json similarity index 100% rename from server/tsconfig.json rename to server/nest/tsconfig.json diff --git a/server/spring/.gitignore b/server/spring/.gitignore new file mode 100644 index 0000000..c2065bc --- /dev/null +++ b/server/spring/.gitignore @@ -0,0 +1,37 @@ +HELP.md +.gradle +build/ +!gradle/wrapper/gradle-wrapper.jar +!**/src/main/**/build/ +!**/src/test/**/build/ + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache +bin/ +!**/src/main/**/bin/ +!**/src/test/**/bin/ + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr +out/ +!**/src/main/**/out/ +!**/src/test/**/out/ + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ + +### VS Code ### +.vscode/ diff --git a/server/spring/build.gradle b/server/spring/build.gradle new file mode 100644 index 0000000..efe1e6c --- /dev/null +++ b/server/spring/build.gradle @@ -0,0 +1,38 @@ +plugins { + id 'java' + id 'org.springframework.boot' version '3.1.8' + id 'io.spring.dependency-management' version '1.1.4' +} + +group = 'catchytape' +version = '0.0.1-SNAPSHOT' + +java { + sourceCompatibility = '17' +} + +configurations { + compileOnly { + extendsFrom annotationProcessor + } +} + +repositories { + mavenCentral() +} + +dependencies { + 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' +} + +tasks.named('bootBuildImage') { + builder = 'paketobuildpacks/builder-jammy-base:latest' +} + +tasks.named('test') { + useJUnitPlatform() +} diff --git a/server/spring/gradle/wrapper/gradle-wrapper.jar b/server/spring/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..d64cd49 Binary files /dev/null and b/server/spring/gradle/wrapper/gradle-wrapper.jar differ diff --git a/server/spring/gradle/wrapper/gradle-wrapper.properties b/server/spring/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..1af9e09 --- /dev/null +++ b/server/spring/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,7 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/server/spring/gradlew b/server/spring/gradlew new file mode 100644 index 0000000..1aa94a4 --- /dev/null +++ b/server/spring/gradlew @@ -0,0 +1,249 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# 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 + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/server/spring/gradlew.bat b/server/spring/gradlew.bat new file mode 100644 index 0000000..93e3f59 --- /dev/null +++ b/server/spring/gradlew.bat @@ -0,0 +1,92 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/server/spring/settings.gradle b/server/spring/settings.gradle new file mode 100644 index 0000000..ebf1ef8 --- /dev/null +++ b/server/spring/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'spring' diff --git a/server/spring/src/main/java/catchytape/spring/Application.java b/server/spring/src/main/java/catchytape/spring/Application.java new file mode 100644 index 0000000..6648ac5 --- /dev/null +++ b/server/spring/src/main/java/catchytape/spring/Application.java @@ -0,0 +1,13 @@ +package catchytape.spring; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class Application { + + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } + +} diff --git a/server/spring/src/main/java/catchytape/spring/HelloCatchyTape.java b/server/spring/src/main/java/catchytape/spring/HelloCatchyTape.java new file mode 100644 index 0000000..a9262f7 --- /dev/null +++ b/server/spring/src/main/java/catchytape/spring/HelloCatchyTape.java @@ -0,0 +1,12 @@ +package catchytape.spring; + +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.GetMapping; + +@RestController +public class HelloCatchyTape { + @GetMapping("/test") + public String test() { + return "hello this is catchy-tape!"; + } +} diff --git a/server/spring/src/main/resources/application.properties b/server/spring/src/main/resources/application.properties new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/server/spring/src/main/resources/application.properties @@ -0,0 +1 @@ + diff --git a/server/spring/src/test/java/catchytape/spring/ApplicationTests.java b/server/spring/src/test/java/catchytape/spring/ApplicationTests.java new file mode 100644 index 0000000..1c1ced8 --- /dev/null +++ b/server/spring/src/test/java/catchytape/spring/ApplicationTests.java @@ -0,0 +1,13 @@ +package catchytape.spring; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class ApplicationTests { + + @Test + void contextLoads() { + } + +} diff --git a/server/tsconfig.build.json b/server/tsconfig.build.json deleted file mode 100644 index 7d3fffd..0000000 --- a/server/tsconfig.build.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "extends": "./tsconfig.json", - "exclude": ["node_modules", "test", "dist", "**/*spec.ts", "cloud-functions"] -}