diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 910bc6d..bcf1fd5 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -18,9 +18,6 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 - - name: Create new builder - run: docker buildx create --use --name mybuilder --driver docker-container - - name: Docker login uses: docker/login-action@v1 with: @@ -34,7 +31,8 @@ jobs: file: ./Dockerfile push: true tags: ${{ secrets.DOCKER_USERNAME }}/${{ secrets.REPOSITORY_NAME }}:${{ github.event.pull_request.number }}, ${{ secrets.DOCKER_USERNAME }}/${{ secrets.REPOSITORY_NAME }}:latest - platforms: linux/amd64,linux/arm64 + cache-from: type=gha + cache-to: type=gha,mode=max - name: Deploy to EC2 uses: appleboy/ssh-action@master @@ -44,10 +42,8 @@ jobs: key: ${{ secrets.SSH_PRIVATE_KEY }} script: | sudo sh -c 'truncate -s 0 /var/lib/docker/containers/*/*-json.log' - cd /${{ secrets.REPOSITORY_NAME }} + cd ~/${{ secrets.REPOSITORY_NAME }} sudo echo "${{ secrets.DOT_ENT }}" > .env sudo docker rm -f ${{ secrets.REPOSITORY_NAME }} || true sudo docker rmi -f ${{ secrets.DOCKER_USERNAME }}/${{ secrets.REPOSITORY_NAME }}:latest || true - sudo docker run -d --name ${{ secrets.REPOSITORY_NAME }} -p 8001:8000 --env-file .env ${{ secrets.DOCKER_USERNAME }}/${{ secrets.REPOSITORY_NAME }}:latest - - sudo docker exec -it ${{ secrets.REPOSITORY_NAME }} python3 manage.py migrate \ No newline at end of file + sudo docker-compose up -d \ No newline at end of file diff --git a/.github/workflows/hotfix.yml b/.github/workflows/hotfix.yml new file mode 100644 index 0000000..f22cd91 --- /dev/null +++ b/.github/workflows/hotfix.yml @@ -0,0 +1,50 @@ +name: Build And Deploy + +on: + push: + branches: + - main + +jobs: + hotfix: + # push 이벤트가 발생했을 때만 실행 + if: github.event_name == 'push' + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Docker login + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Docker Build and Push + uses: docker/build-push-action@v2 + with: + context: . + file: ./Dockerfile + push: true + tags: ${{ secrets.DOCKER_USERNAME }}/${{ secrets.REPOSITORY_NAME }}:latest + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Deploy to EC2 + uses: appleboy/ssh-action@master + with: + host: ${{ secrets.HOST }} + username: ubuntu + key: ${{ secrets.SSH_PRIVATE_KEY }} + script: | + sudo sh -c 'truncate -s 0 /var/lib/docker/containers/*/*-json.log' + cd ~/${{ secrets.REPOSITORY_NAME }} + sudo echo "${{ secrets.DOT_ENT }}" > .env + sudo docker rm -f ${{ secrets.REPOSITORY_NAME }} || true + sudo docker rmi -f ${{ secrets.DOCKER_USERNAME }}/${{ secrets.REPOSITORY_NAME }}:latest || true + sudo docker run -d --name ${{ secrets.REPOSITORY_NAME }} -p 8001:8000 --env-file .env ${{ secrets.DOCKER_USERNAME }}/${{ secrets.REPOSITORY_NAME }}:latest + + sudo docker exec ${{ secrets.REPOSITORY_NAME }} python3 manage.py migrate \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 2386dfd..1bbfaca 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM twoone14/dp-base-image:0.2 +FROM twoone14/dp-base-image:latest WORKDIR /app diff --git a/diary/textrank.py b/diary/textrank.py index 13f0ab1..9876e85 100644 --- a/diary/textrank.py +++ b/diary/textrank.py @@ -1,6 +1,5 @@ import re import numpy as np -from hanspell import spell_checker from konlpy.tag import Okt from sklearn.feature_extraction.text import CountVectorizer from sklearn.feature_extraction.text import TfidfVectorizer @@ -23,7 +22,7 @@ def sent_normalize(self, sentence): sentence = re.sub(pattern=self.signpattern, repl=self.repl, string=sentence) # 맞춤법 수정 - return spell_checker.check(sentence).checked + return sentence class SentenceTokenizer: @@ -52,9 +51,12 @@ def get_nouns(sentences): okt = Okt() + stopword = ["오늘", "내일", "빨리", "바쁘게"] + # 명사 추출후 명사 리스트를 문자열로 변환하는 함수 def join_nouns(sentence): - return ' '.join(okt.nouns(str(sentence))) + return ' '.join([noun for noun in okt.nouns(str(sentence)) + if noun not in stopword]) # 명사 추출 return list(map(join_nouns, sentences))