From 37dc22c28e661ba0678ac786dc62ca7d0baa9b61 Mon Sep 17 00:00:00 2001 From: Bob Sin Date: Sat, 6 Apr 2024 02:09:40 +0900 Subject: [PATCH] =?UTF-8?q?[KAN-17]=20=EC=9E=90=EB=8F=99=EC=99=84=EC=84=B1?= =?UTF-8?q?=20=EB=B0=B0=EC=B9=98=20ci/cd=20=EA=B5=AC=EC=B6=95=20(#4)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [KAN-17] 자동완성 배치 ci/cd 구축 * [KAN-17] 자동완성 배치 ci/cd 구축 - 테스트 * [KAN-17] 자동완성 배치 ci/cd 구축 - 테스트 * [KAN-17] 테스트 롤백 --- .github/workflows/autocomplete-batch-job.yml | 34 ++++++++++++++++++++ Dockerfile | 9 ++++++ main.py | 6 ++-- requirements.txt | 2 ++ 4 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/autocomplete-batch-job.yml create mode 100644 Dockerfile create mode 100644 requirements.txt diff --git a/.github/workflows/autocomplete-batch-job.yml b/.github/workflows/autocomplete-batch-job.yml new file mode 100644 index 0000000..b31b433 --- /dev/null +++ b/.github/workflows/autocomplete-batch-job.yml @@ -0,0 +1,34 @@ +name: Autocomplete Batch Job + +on: + workflow_dispatch: + push: + branches: + - main + schedule: + - cron: '0 0 * * *' + +jobs: + batch-job: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Docker Build And Push + run: | + docker login -u ${{ secrets.USERNAME }} -p ${{ secrets.PASSWORD }} + docker build -t skku-autocomplete-batch . + docker tag skku-autocomplete-batch sinkyoungdeok/skku-autocomplete-batch + docker push sinkyoungdeok/skku-autocomplete-batch + - name: Deploy Prod + uses: appleboy/ssh-action@v0.1.4 + with: + key: ${{ secrets.SSH_KEY }} + host: ${{ secrets.HOST_NAME }} + username: ubuntu + port: 22 + script: | + docker login -u ${{ secrets.USERNAME }} -p ${{ secrets.PASSWORD }} + docker pull sinkyoungdeok/skku-autocomplete-batch + + docker run --net ubuntu_default sinkyoungdeok/skku-autocomplete-batch + diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..172a647 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM python:3.8-slim + +COPY requirements.txt requirements.txt +COPY restaurants.csv restaurants.csv +COPY main.py main.py + +RUN pip install -r requirements.txt + +ENTRYPOINT ["python3", "main.py"] \ No newline at end of file diff --git a/main.py b/main.py index ef4ef0a..8630a3c 100644 --- a/main.py +++ b/main.py @@ -111,9 +111,9 @@ def apply_highlighting(org_data, highlighted_data): else: data[gd] = [json_data] -r = redis.Redis(host='localhost', port=6379, db=0) +r = redis.Redis(host='skku-redis', port=6379, db=0) version = '20240403232030' -r.set('restaurant:v1:version', version) +r.setex('restaurant:v1:version', 3600 * 24 * 2, version) for key, value in data.items(): - r.set('restaurant:v1:' + version + ':' + key, json.dumps(value)) + r.setex('restaurant:v1:' + version + ':' + key, 3600 * 24 * 2, json.dumps(value)) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..df2003f --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +redis +pandas \ No newline at end of file