From 239205ea5ef3002566876d08bd78b7287e1cd13e Mon Sep 17 00:00:00 2001 From: DongGun Lee <124961407+nicerjs23@users.noreply.github.com> Date: Sun, 6 Oct 2024 17:13:14 +0900 Subject: [PATCH 1/2] =?UTF-8?q?[Fix]=20#120=20-=20=EB=B0=B0=ED=8F=AC?= =?UTF-8?q?=ED=8F=B0=ED=8A=B8=20=EC=A0=81=EC=9A=A9=EC=98=A4=EB=A5=98=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20(#121)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fonts/AppleSDGothicNeoB.ttf | Bin .../fonts/AppleSDGothicNeoH.ttf | Bin .../fonts/AppleSDGothicNeoL.ttf | Bin .../fonts/AppleSDGothicNeoM.ttf | Bin .../fonts/AppleSDGothicNeoR.ttf | Bin .../fonts/AppleSDGothicNeoT.ttf | Bin .../fonts/AppleSDGothicNeoUL.ttf | Bin .../fonts/NanumSquareRoundB.ttf | Bin .../fonts/NanumSquareRoundEB.ttf | Bin .../fonts/NanumSquareRoundL.ttf | Bin .../fonts/NanumSquareRoundOTFB.otf | Bin .../fonts/NanumSquareRoundR.ttf | Bin src/styles/global.js | 24 +++++++++--------- 13 files changed, 12 insertions(+), 12 deletions(-) rename {src/assets => public}/fonts/AppleSDGothicNeoB.ttf (100%) rename {src/assets => public}/fonts/AppleSDGothicNeoH.ttf (100%) rename {src/assets => public}/fonts/AppleSDGothicNeoL.ttf (100%) rename {src/assets => public}/fonts/AppleSDGothicNeoM.ttf (100%) rename {src/assets => public}/fonts/AppleSDGothicNeoR.ttf (100%) rename {src/assets => public}/fonts/AppleSDGothicNeoT.ttf (100%) rename {src/assets => public}/fonts/AppleSDGothicNeoUL.ttf (100%) rename {src/assets => public}/fonts/NanumSquareRoundB.ttf (100%) rename {src/assets => public}/fonts/NanumSquareRoundEB.ttf (100%) rename {src/assets => public}/fonts/NanumSquareRoundL.ttf (100%) rename {src/assets => public}/fonts/NanumSquareRoundOTFB.otf (100%) rename {src/assets => public}/fonts/NanumSquareRoundR.ttf (100%) diff --git a/src/assets/fonts/AppleSDGothicNeoB.ttf b/public/fonts/AppleSDGothicNeoB.ttf similarity index 100% rename from src/assets/fonts/AppleSDGothicNeoB.ttf rename to public/fonts/AppleSDGothicNeoB.ttf diff --git a/src/assets/fonts/AppleSDGothicNeoH.ttf b/public/fonts/AppleSDGothicNeoH.ttf similarity index 100% rename from src/assets/fonts/AppleSDGothicNeoH.ttf rename to public/fonts/AppleSDGothicNeoH.ttf diff --git a/src/assets/fonts/AppleSDGothicNeoL.ttf b/public/fonts/AppleSDGothicNeoL.ttf similarity index 100% rename from src/assets/fonts/AppleSDGothicNeoL.ttf rename to public/fonts/AppleSDGothicNeoL.ttf diff --git a/src/assets/fonts/AppleSDGothicNeoM.ttf b/public/fonts/AppleSDGothicNeoM.ttf similarity index 100% rename from src/assets/fonts/AppleSDGothicNeoM.ttf rename to public/fonts/AppleSDGothicNeoM.ttf diff --git a/src/assets/fonts/AppleSDGothicNeoR.ttf b/public/fonts/AppleSDGothicNeoR.ttf similarity index 100% rename from src/assets/fonts/AppleSDGothicNeoR.ttf rename to public/fonts/AppleSDGothicNeoR.ttf diff --git a/src/assets/fonts/AppleSDGothicNeoT.ttf b/public/fonts/AppleSDGothicNeoT.ttf similarity index 100% rename from src/assets/fonts/AppleSDGothicNeoT.ttf rename to public/fonts/AppleSDGothicNeoT.ttf diff --git a/src/assets/fonts/AppleSDGothicNeoUL.ttf b/public/fonts/AppleSDGothicNeoUL.ttf similarity index 100% rename from src/assets/fonts/AppleSDGothicNeoUL.ttf rename to public/fonts/AppleSDGothicNeoUL.ttf diff --git a/src/assets/fonts/NanumSquareRoundB.ttf b/public/fonts/NanumSquareRoundB.ttf similarity index 100% rename from src/assets/fonts/NanumSquareRoundB.ttf rename to public/fonts/NanumSquareRoundB.ttf diff --git a/src/assets/fonts/NanumSquareRoundEB.ttf b/public/fonts/NanumSquareRoundEB.ttf similarity index 100% rename from src/assets/fonts/NanumSquareRoundEB.ttf rename to public/fonts/NanumSquareRoundEB.ttf diff --git a/src/assets/fonts/NanumSquareRoundL.ttf b/public/fonts/NanumSquareRoundL.ttf similarity index 100% rename from src/assets/fonts/NanumSquareRoundL.ttf rename to public/fonts/NanumSquareRoundL.ttf diff --git a/src/assets/fonts/NanumSquareRoundOTFB.otf b/public/fonts/NanumSquareRoundOTFB.otf similarity index 100% rename from src/assets/fonts/NanumSquareRoundOTFB.otf rename to public/fonts/NanumSquareRoundOTFB.otf diff --git a/src/assets/fonts/NanumSquareRoundR.ttf b/public/fonts/NanumSquareRoundR.ttf similarity index 100% rename from src/assets/fonts/NanumSquareRoundR.ttf rename to public/fonts/NanumSquareRoundR.ttf diff --git a/src/styles/global.js b/src/styles/global.js index 5312e3a..cbd16b5 100644 --- a/src/styles/global.js +++ b/src/styles/global.js @@ -27,59 +27,59 @@ i {font-style:normal} // 애플 SD 산돌고딕 Neo 폰트 설정 @font-face { font-family: "AppleSDGothicNeoH00"; - src: url("src/assets/fonts/AppleSDGothicNeoH.ttf") format("truetype"); + src: url("/fonts/AppleSDGothicNeoH.ttf") format("truetype"); } @font-face { font-family: "AppleSDGothicNeoB00"; - src: url("src/assets/fonts/AppleSDGothicNeoB.ttf") format("truetype"); + src: url("/fonts/AppleSDGothicNeoB.ttf") format("truetype"); } @font-face { font-family: "AppleSDGothicNeoL00"; - src: url("src/assets/fonts/AppleSDGothicNeoL.ttf") format("truetype"); + src: url("/fonts/AppleSDGothicNeoL.ttf") format("truetype"); } @font-face { font-family: "AppleSDGothicNeoUL00"; - src: url("src/assets/fonts/AppleSDGothicNeoUL.ttf") format("truetype"); + src: url("/fonts/AppleSDGothicNeoUL.ttf") format("truetype"); } @font-face { font-family: "AppleSDGothicNeoT0C"; - src: url("src/assets/fonts/AppleSDGothicNeoT.ttf") format("truetype"); + src: url("/fonts/AppleSDGothicNeoT.ttf") format("truetype"); } @font-face { font-family: "AppleSDGothicNeoR00"; - src: url("src/assets/fonts/AppleSDGothicNeoR.ttf") format("truetype"); + src: url("/fonts/AppleSDGothicNeoR.ttf") format("truetype"); } @font-face { font-family: "AppleSDGothicNeoM00"; - src: url("src/assets/fonts/AppleSDGothicNeoM.ttf") format("truetype"); + src: url("/fonts/AppleSDGothicNeoM.ttf") format("truetype"); } @font-face { font-family: "NanumSquareRoundOTF"; - src: url("src/assets/fonts/NanumSquareRoundOTFB.ttf") format("truetype"); + src: url("/fonts/NanumSquareRoundOTFB.ttf") format("truetype"); } //나눔 스퀘어 라운드 폰트 설정 @font-face { font-family: "NanumSquareRoundB"; - src: url("src/assets/fonts/NanumSquareRoundB.ttf") format("truetype"); + src: url("/fonts/NanumSquareRoundB.ttf") format("truetype"); } @font-face { font-family: "NanumSquareRoundEB"; - src: url("src/assets/fonts/NanumSquareRoundEB.ttf") format("truetype"); + src: url("/fonts/NanumSquareRoundEB.ttf") format("truetype"); } @font-face { font-family: "NanumSquareRoundR"; - src: url("src/assets/fonts/NanumSquareRoundR.ttf") format("truetype"); + src: url("/fonts/NanumSquareRoundR.ttf") format("truetype"); } @font-face { font-family: "NanumSquareRoundL"; - src: url("src/assets/fonts/NanumSquareRoundL.ttf") format("truetype"); + src: url("/fonts/NanumSquareRoundL.ttf") format("truetype"); } From 6d034359a2351af6004368eaba02d1626b8d00ab Mon Sep 17 00:00:00 2001 From: sayyyho <323psh@naver.com> Date: Sun, 6 Oct 2024 17:37:05 +0900 Subject: [PATCH 2/2] =?UTF-8?q?[Fix]=20-=20=EB=A7=88=EC=9D=B4=EA=B7=B8?= =?UTF-8?q?=EB=A0=88=EC=9D=B4=EC=85=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy.yml | 67 +++++++++++++++++++++++++----------- Dockerfile | 40 +++++++++++++++++++++ nginx.conf | 11 ++++++ 3 files changed, 97 insertions(+), 21 deletions(-) create mode 100644 Dockerfile create mode 100644 nginx.conf diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index a525345..b99f898 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,32 +1,57 @@ -name: Deploy +name: Deploy to AWS EC2 using Docker on: push: - branches: ["main"] + branches: + - main + +env: + DOCKER_IMAGE_NAME: ${{ secrets.DOCKER_IMAGE_NAME }} + EC2_HOST: ${{ secrets.EC2_HOST }} + EC2_SSH_USER: ${{ secrets.EC2_SSH_USER }} + PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} jobs: - build: + build-and-push-docker: runs-on: ubuntu-latest - container: - image: pandoc/latex steps: - - uses: actions/checkout@v3 + - name: Checkout + uses: actions/checkout@v3 + + - name: Create .env file + run: | + echo "VITE_BASE_URL=${{ secrets.VITE_BASE_URL }}" > .env + echo "VITE_GA_MEASUREMENT_ID=${{ secrets.VITE_GA_MEASUREMENT_ID }}" >> .env + + - name: Build the Docker image + run: docker build . --file Dockerfile --tag ${{ env.DOCKER_IMAGE_NAME }}:latest - - name: creates output - run: sh ./build.sh + - name: Login to Docker Hub using Access Token + run: echo "${{ secrets.DOCKERHUB_TOKEN }}" | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin - - name: Pushes to origin repository - id: push_directory - uses: cpina/github-action-push-to-another-repository@main - env: - API_TOKEN_GITHUB: ${{ secrets.AUTO_ACTIONS }} + - name: Push the Docker image + run: docker push ${{ env.DOCKER_IMAGE_NAME }}:latest + + deploy-to-ec2: + needs: build-and-push-docker + runs-on: ubuntu-latest + + steps: + - name: Deploy to EC2 + uses: appleboy/ssh-action@master with: - source-directory: "output" - destination-github-username: sayyyho - destination-repository-name: 2024_fall_festival_front - user-email: "323psh@naver.com" - commit-message: "배포" - - - name: Test get variable exported by push-to-another-repository - run: echo $DESTINATION_CLONED_DIRECTORY + host: ${{ env.EC2_HOST }} + username: ${{ env.EC2_SSH_USER }} + key: ${{ env.PRIVATE_KEY }} + script: | + CONTAINER_ID=$(sudo docker ps -aq --filter "name=kaboo-connection-container") + + if [ ! -z "$CONTAINER_ID" ]; then + sudo docker stop $CONTAINER_ID || true + sudo docker rm -f $CONTAINER_ID || true + fi + + sudo docker pull ${{ env.DOCKER_IMAGE_NAME }}:latest + sudo docker run --name kaboo-connection-container -d -p 80:80 -p 3000:3000 -e TZ=Asia/Seoul ${{ env.DOCKER_IMAGE_NAME }}:latest + sudo docker image prune -f diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a5350a4 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,40 @@ +# Base image with Node.js +FROM node:18-alpine as build + +# Set working directory +WORKDIR /app + +# Install dependencies +COPY package.json package-lock.json ./ +RUN npm install + +# Copy all files +COPY . . + +# Build the application +RUN npm run build + +# Production image for Nginx +FROM nginx:alpine + +# Install Node.js in Nginx container +RUN apk add --no-cache nodejs npm + +# Copy built application +COPY --from=build /app/dist /usr/share/nginx/html + +# Copy Node.js server files +COPY --from=build /app/server.cjs /app/server.cjs +COPY --from=build /app/node_modules /app/node_modules + +# Remove default nginx config +RUN rm /etc/nginx/conf.d/default.conf + +# Copy custom nginx config +COPY ./nginx.conf /etc/nginx/conf.d + +# Expose ports +EXPOSE 80 3000 + +# Run both Nginx and Node.js server +CMD ["sh", "-c", "node /app/server.cjs & nginx -g 'daemon off;'"] diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..14029f4 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,11 @@ +server { + listen 80; + server_name dgu-booth.site; + + location / { + root /usr/share/nginx/html; + index index.html index.htm; + try_files $uri $uri/ /index.html; + } + +} \ No newline at end of file