From 159ab900dbec1318ddf26942d81c3a115cf059b2 Mon Sep 17 00:00:00 2001 From: Hugo Ferrando Seage Date: Tue, 28 Jul 2020 12:11:51 +0200 Subject: [PATCH] Remove travis with github actions Deploy to DO k8s --- .github/dependabot.yml | 18 +++++++++++++++++ .github/workflows/push.yml | 41 ++++++++++++++++++++++++++++++++++++++ .github/workflows/test.yml | 41 ++++++++++++++++++++++++++++++++++++++ .travis.yml | 11 ---------- Dockerfile | 23 +++++++++++++++++++++ manifest.yaml | 37 ++++++++++++++++++++++++++++++++++ 6 files changed, 160 insertions(+), 11 deletions(-) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/push.yml create mode 100644 .github/workflows/test.yml delete mode 100644 .travis.yml create mode 100644 Dockerfile create mode 100644 manifest.yaml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..7583c03 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,18 @@ +version: 2 +updates: +- package-ecosystem: pip + directory: "/" + schedule: + interval: weekly + day: friday + time: "18:00" + timezone: Europe/Madrid + open-pull-requests-limit: 10 +- package-ecosystem: docker + directory: "/" + schedule: + interval: weekly + day: friday + time: "18:00" + timezone: Europe/Madrid + open-pull-requests-limit: 10 diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml new file mode 100644 index 0000000..e5cec74 --- /dev/null +++ b/.github/workflows/push.yml @@ -0,0 +1,41 @@ +name: Backend Deployment + +on: + push: + branches: + - master + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Build and push Frotnend image + uses: docker/build-push-action@v1 + with: + username: hugo19941994 + password: ${{ secrets.DOCKER_PASSWORD }} + repository: hugo19941994/moviepepper-backend + tags: latest + + - name: Install doctl + uses: digitalocean/action-doctl@v2 + with: + token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} + + - name: Save DigitalOcean kubeconfig + run: doctl kubernetes cluster kubeconfig save k8s-1-18-6-do-0-lon1-1595844489030 + + - name: Deploy to DigitalOcean Kubernetes + run: kubectl apply -f manifest.yaml + + - name: Deploy to DigitalOcean Kubernetes + run: kubectl rollout restart deployment/moviepepper-backend + + - name: Verify deployment + run: kubectl rollout status deployment/moviepepper-backend + + diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..9b2ba58 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,41 @@ +name: Backend CI + +on: [pull_request] + +jobs: + build: + runs-on: ubuntu-latest + + strategy: + matrix: + python-version: [3.8.x] + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Use Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + node-version: ${{ matrix.python-version }} + + - name: Install pipenv + run: sudo pip install pipenv + + - name: Install dependencies using Pipenv + run: pipenv install --deploy --system + + - name: Download deps + run: | + python -m textblob.download_corpora + python -m nltk.downloader stopwords + + - name: Test moviepepper-backend + run: | + coverage run --concurrency=multiprocessing tests.py + coverage combine + coveralls + env: + CI: true + + diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 04ffc56..0000000 --- a/.travis.yml +++ /dev/null @@ -1,11 +0,0 @@ -language: python -python: -- '3.6' -install: -- pip install -r requirements.txt -- python -m textblob.download_corpora -- python -m nltk.downloader stopwords -script: -- coverage run --concurrency=multiprocessing tests.py -- coverage combine -- coveralls diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..846dd7c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +FROM python:3.8-alpine + +RUN pip install pipenv + +WORKDIR /app +COPY Pipfile* /app/ + +RUN pipenv install --system + +COPY . /app/ + +# 1 scrape +WORKDIR /app/movie_scrape +RUN START_URL="http://www.imdb.com/search/title?groups=top_1000&sort=user_rating,desc&page=1&ref" ./scrap.sh + +# 2 Calculate recommendations +WORKDIR /app +RUN python tfidf-lsa.py +RUN python doc2vec.py + +# 3 Serve server +CMD python server.py + diff --git a/manifest.yaml b/manifest.yaml new file mode 100644 index 0000000..c59a505 --- /dev/null +++ b/manifest.yaml @@ -0,0 +1,37 @@ +--- +kind: Service +apiVersion: v1 +metadata: + name: moviepepper-backend +spec: + type: NodePort + selector: + app: moviepepper-backend + ports: + - name: http + protocol: TCP + port: 80 + targetPort: 3000 +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: moviepepper-backend +spec: + replicas: 2 + selector: + matchLabels: + app: moviepepper-backend + template: + metadata: + labels: + app: moviepepper-backend + spec: + containers: + - name: moviepepper-backend + image: hugo19941994/moviepepper-backend + ports: + - containerPort: 5000 + protocol: TCP + +