diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..b06adf7 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,11 @@ +node_modules +npm-debug.log +build +.git +.gitignore +README.md +.env +.nyc_output +coverage +.vscode +.idea \ No newline at end of file diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..b7d7a25 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,39 @@ +name: Frontend CD with Docker Hub +on: + push: + branches: + - dev # dev push되었을 때 yml 실행 +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{secrets.DOCKERHUB_USERNAME}} # 도커 허브 이름 + password: ${{secrets.DOCKERHUB_TOKEN}} # 도커 허브 access token + - name: Build and Release + run: | + docker build \ + --build-arg VITE_API_URL=${{ secrets.VITE_API_URL }} \ + -t ${{secrets.DOCKERHUB_REPO}} . + docker tag ${{secrets.DOCKERHUB_REPO}}:latest ${{secrets.DOCKERHUB_USERNAME}}/${{secrets.DOCKERHUB_REPO}}:latest + docker push ${{secrets.DOCKERHUB_USERNAME}}/${{secrets.DOCKERHUB_REPO}}:latest + - name: Deploy to server + uses: appleboy/ssh-action@master + id: deploy + with: + host: ${{ secrets.HOST }} + username: ${{ secrets.USERNAME }} + key: ${{ secrets.KEY }} + script: | + sudo docker rm -f $(docker ps -aqf "name=^${{secrets.DOCKERHUB_REPO}}") + sudo docker pull ${{secrets.DOCKERHUB_USERNAME}}/${{secrets.DOCKERHUB_REPO}}:latest + sudo docker run \ + -e VITE_API_URL=${{ secrets.VITE_API_URL }} \ + -v /etc/letsencrypt:/etc/letsencrypt:ro \ + -d -p 80:80 -p 443:443 \ + --name ${{secrets.DOCKERHUB_REPO}} \ + ${{secrets.DOCKERHUB_USERNAME}}/${{secrets.DOCKERHUB_REPO}}:latest + sudo docker image prune -f \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3bef82f --- /dev/null +++ b/.gitignore @@ -0,0 +1,30 @@ +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. + +# intellij +/.idea + +# claude +/.claude + +# dependencies +/node_modules +/.pnp +.pnp.js + +# testing +/coverage + +# production +/build + +# misc +.DS_Store +.env +.env.local +.env.development.local +.env.test.local +.env.production.local + +npm-debug.log* +yarn-debug.log* +yarn-error.log* diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..cd44774 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,40 @@ +# 멀티 스테이지 빌드 +# 1단계: 빌드 스테이지 +FROM node:20-alpine AS builder + +WORKDIR /app + +# package.json과 package-lock.json 복사 +COPY package*.json ./ + +# 의존성 설치 (빌드에 필요한 devDependencies 포함) +RUN npm ci + +# 소스 코드 복사 +COPY . . + +# build-time ARG 정의 +ARG VITE_API_URL +ENV VITE_API_URL=$VITE_API_URL + +# Vite로 빌드 +RUN echo "VITE_API_URL=$VITE_API_URL" +RUN npm run build + +# 2단계: 프로덕션 스테이지 +FROM nginx:alpine + +# 기본 nginx 설정 제거 +RUN rm /etc/nginx/conf.d/default.conf + +# nginx 템플릿 복사 +COPY nginx.conf.template /etc/nginx/templates/ + +# 빌드된 정적 파일 복사 +COPY --from=builder /app/build /usr/share/nginx/html + +# 포트 80 노출 +EXPOSE 80 + +# nginx 실행 +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..b87cb00 --- /dev/null +++ b/README.md @@ -0,0 +1,46 @@ +# Getting Started with Create React App + +This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). + +## Available Scripts + +In the project directory, you can run: + +### `npm start` + +Runs the app in the development mode.\ +Open [http://localhost:3000](http://localhost:3000) to view it in the browser. + +The page will reload if you make edits.\ +You will also see any lint errors in the console. + +### `npm test` + +Launches the test runner in the interactive watch mode.\ +See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. + +### `npm run build` + +Builds the app for production to the `build` folder.\ +It correctly bundles React in production mode and optimizes the build for the best performance. + +The build is minified and the filenames include the hashes.\ +Your app is ready to be deployed! + +See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. + +### `npm run eject` + +**Note: this is a one-way operation. Once you `eject`, you can’t go back!** + +If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. + +Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. + +You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. + +## Learn More + +You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). + +To learn React, check out the [React documentation](https://reactjs.org/). diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..8e1fc9e --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,13 @@ +version: '3.8' + +services: + frontend: + build: . + ports: + - "5173:80" + networks: + - app-network + +networks: + app-network: + driver: bridge \ No newline at end of file diff --git a/index.html b/index.html new file mode 100644 index 0000000..c7e182b --- /dev/null +++ b/index.html @@ -0,0 +1,25 @@ + + +
+ + + + + + + + + + + ++ CS25에서 요청하신 인증을 위해 아래의 코드를 입력해주세요. +
+ + {/* Verification Code */} +인증코드
+중요 안내
+해당 코드는 3분간 유효합니다.
+
+ AI가 준비한 맞춤형 문제를 확인하세요
+
+ 안녕하세요! CS25에서 오늘의 맞춤형 CS 문제를 보내드립니다.
+ 데일리 문제와 상세한 AI 해설로 CS 지식을 향상시켜보세요.
+
+ 이 메일은 {toEmail} 계정으로 발송되었습니다. +
++ 매일 새로운 CS 지식으로 성장하는 개발자가 되어보세요! 🚀 +
+
+
+ 소셜 계정으로 간편하게 로그인하고
+ AI가 전하는 더 많은 기능을 경험해보세요!
+
{formData.email}로
+인증번호가 포함된 메일을 발송했습니다.
+
+ 선택하신 요일에 맞춰
+ 기술 면접 문제를 발송해드리겠습니다.
+
이메일: {formData.email}
+분야: {formData.categories.map(cat => + categories.find(c => c.id === cat)?.label).join(', ')}
+요일: {formData.weekdays.map(day => + weekdays.find(w => w.id === day)?.label).join(', ')}
+구독 기간: {periods.find(p => p.id === formData.period)?.label}
++ AI가 생성하고 해설하는{' '} + + 개인화된 + {' '} + CS 지식 학습 경험{' '} + ✨ +
++ {feature.description} +
+ ++ 💡 {feature.details} +
+
+ AI가 매일 새로운 CS 문제를 생성하고 상세히 해설
+ 개인 수준에 맞는 알고리즘, 자료구조, 운영체제 등
+
프로필을 불러오는 중...
++ 학습 현황과 성과를 확인해보세요! +
+이메일 알림 설정을 관리하세요
+ ++ 꾸준한 문제 풀이를 통해 점수를 높이고 랭킹을 올려보세요! +
+틀린 문제를 불러오는 중...
++ {quiz.commentary} +
+아직 틀린 문제가 없습니다. 계속 열심히 해보세요!
+정답률 데이터를 불러오는 중...
+문제를 풀어보시면 카테고리별 정답률을 확인할 수 있습니다!
+퀴즈를 불러올 수 없습니다.
+잠시 후 다시 시도해주세요.
+{currentQuiz.explanation}
++ 정답: {currentQuiz.options.find(opt => opt.id === currentQuiz.correctAnswer)?.text} +
++ 매일 새로운 CS 지식을 확인하고 실력을 향상시켜보세요 +
+구독정보가 성공적으로 수정되었습니다.
+구독정보 수정에 실패했습니다.
+ {formatErrorMessage(errorMessage)} +구독을 해지하시겠습니까?
+구독을 해지하면 문제 발송이 중단됩니다.
+ +구독정보를 불러오는 중...
+구독정보를 불러올 수 없습니다.
+ +구독 설정을 변경할 수 있습니다.
+{subscriptionData?.email}
+이메일은 변경할 수 없습니다.
++ 아래와 같은 형태의 맞춤형 메일을 받아보실 수 있습니다. +
+선택지를 먼저 클릭해주세요!
+답안을 입력해주세요!
+{errorMessage}
+퀴즈를 불러오는 중...
++ 매일 새로운 CS 지식을 확인하고 실력을 향상시켜보세요 +
+