Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deploy 0.2 #31

Merged
merged 7 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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
sudo docker-compose up -d
50 changes: 50 additions & 0 deletions .github/workflows/hotfix.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM twoone14/dp-base-image:0.2
FROM twoone14/dp-base-image:latest

WORKDIR /app

Expand Down
8 changes: 5 additions & 3 deletions diary/textrank.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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))
Expand Down
Loading