From 6244208ed6e566eea51aed7b73c4a8c7727f46ab Mon Sep 17 00:00:00 2001 From: TheBeastLT Date: Thu, 26 Mar 2020 18:34:29 +0100 Subject: [PATCH] adds docker deployment --- .github/workflows/deploy-pipeline.yml | 28 ------------------ .github/workflows/deploy.yml | 42 +++++++++++++++++++++++++++ addon/.dockerignore | 3 ++ addon/Dockerfile | 12 ++++++++ addon/lib/manifest.js | 4 +-- now.json | 20 +++---------- 6 files changed, 63 insertions(+), 46 deletions(-) delete mode 100644 .github/workflows/deploy-pipeline.yml create mode 100644 .github/workflows/deploy.yml create mode 100644 addon/.dockerignore create mode 100644 addon/Dockerfile diff --git a/.github/workflows/deploy-pipeline.yml b/.github/workflows/deploy-pipeline.yml deleted file mode 100644 index 755c8c8..0000000 --- a/.github/workflows/deploy-pipeline.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: Deploy Pipeline -on: - push: - branches: - - 'master' - -jobs: - deploy: - name: Deploy - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v1 - - - run: sed -i -e "s~@database-uri~$DATABASE_URI~g" app.yaml - env: - DATABASE_URI: ${{secrets.DATABASE_URI}} - - - run: sed -i -e "s~@mongodb-uri~$MONGODB_URI~g" app.yaml - env: - MONGODB_URI: ${{secrets.MONGODB_URI}} - - - uses: actions-hub/gcloud@master - env: - PROJECT_ID: ${{secrets.GCLOUD_PROJECT_ID}} - APPLICATION_CREDENTIALS: ${{secrets.GOOGLE_APPLICATION_CREDENTIALS}} - with: - args: app -q deploy app.yaml --promote \ No newline at end of file diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..5dc7b58 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,42 @@ +name: Deploy + +on: + push: + branches: master + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v1 + + - name: Create Docker image + run: | + docker build -t torrentio-addon:latest ./addon/ + docker save torrentio-addon:latest > torrentio_addon_latest.tar + + - name: Upload Docker image + uses: appleboy/scp-action@master + with: + host: ${{ secrets.SSH_HOST }} + username: ${{ secrets.SSH_USERNAME }} + port: ${{ secrets.SSH_PORT }} + key: ${{ secrets.SSH_KEY }} + source: torrentio_addon_latest.tar + target: /tmp/docker + overwrite: true + + - name: Deploy Docker image + uses: appleboy/ssh-action@master + with: + host: ${{ secrets.SSH_HOST }} + username: ${{ secrets.SSH_USERNAME }} + port: ${{ secrets.SSH_PORT }} + key: ${{ secrets.SSH_KEY }} + script: | + docker load -i /tmp/docker/torrentio_addon_latest.tar + docker stop torrentio-addon + docker rm torrentio-addon + docker run -p 80:7000 -d --name torrentio-addon --restart always -e MONGODB_URI=${{ secrets.MONGODB_URI }} -e DATABASE_URI=${{ secrets.DATABASE_URI }} -e RESOLVER_HOST=${{ secrets.RESOLVER_HOST }} torrentio-addon:latest + docker image prune -f diff --git a/addon/.dockerignore b/addon/.dockerignore new file mode 100644 index 0000000..e32c404 --- /dev/null +++ b/addon/.dockerignore @@ -0,0 +1,3 @@ +node_modules +npm-debug.log +**/.env \ No newline at end of file diff --git a/addon/Dockerfile b/addon/Dockerfile new file mode 100644 index 0000000..f385ac7 --- /dev/null +++ b/addon/Dockerfile @@ -0,0 +1,12 @@ +FROM node:12-alpine + +RUN apk update && apk upgrade && \ + apk add --no-cache git + +WORKDIR /home/node/app + +COPY package*.json ./ +RUN npm ci --only-production +COPY . . + +CMD [ "node", "index.js" ] \ No newline at end of file diff --git a/addon/lib/manifest.js b/addon/lib/manifest.js index 74e37ee..272f577 100644 --- a/addon/lib/manifest.js +++ b/addon/lib/manifest.js @@ -12,9 +12,9 @@ function manifest({ providers, realdebrid } = {}) { const realDebridDesc = realdebrid ? ' and RealDebrid enabled' : ''; return { id: 'com.stremio.torrentio.addon', - version: '0.0.1-beta', + version: '0.0.2', name: 'Torrentio', - description: '[BETA] Provides torrent streams from scraped torrent providers.' + description: 'Provides torrent streams from scraped torrent providers.' + ` ${providersDesc} ${providersList.join(', ')}${realDebridDesc}.` + ' To configure providers, RealDebrid support and other settings visit www.torrentio.now.sh', catalogs: [], diff --git a/now.json b/now.json index ef9dfed..cdb7bcb 100644 --- a/now.json +++ b/now.json @@ -1,28 +1,16 @@ { "version": 2, - "builds": [ - { - "src": "/addon/**/*.js", - "use": "@now/node" - } - ], "routes": [ - { - "src": "/static/(.*)", - "dest": "/addon/static/$1" - }, { "src": "/(.*)", - "dest": "/addon/serverless.js" + "status": 308, + "headers": { + "Location": "https://torrentio.strem.fun/$1" + } } ], "github": { "silent": true - }, - "env": { - "MONGODB_URI": "@mongodb-uri", - "DATABASE_URI": "@database-uri", - "RESOLVER_HOST": "@torrentio-resolver-host" } }