diff --git a/.github/workflows/build-prod.yml b/.github/workflows/build-prod.yml index 8356fdab0..80a834bb0 100644 --- a/.github/workflows/build-prod.yml +++ b/.github/workflows/build-prod.yml @@ -8,9 +8,14 @@ name: Build Prod env: APP_DIR: /root/teledrive DEV_USER: root - DEV_HOST: 128.199.160.37 - DEV_HOST_1: 134.122.90.11 - DEV_HOST_2: 104.131.15.43 + DEV_HOST_SG_1: 159.223.92.212 + DEV_HOST_SG_2: 157.245.151.235 + DEV_HOST_GE_1: 159.89.108.133 + DEV_HOST_GE_2: 165.227.157.185 + DEV_HOST_GE_3: 134.209.247.90 + DEV_HOST_US_1: 143.198.114.6 + DEV_HOST_US_2: 159.223.96.246 + DEV_HOST_US_3: 137.184.203.195 jobs: build: @@ -39,13 +44,13 @@ jobs: if: ${{ github.event_name == 'push' }} run: tar -czf build-web.tar.gz web/node_modules web/build - # Upload to SGP + # Upload to SG_1 - name: Upload build-root.tar.gz uses: appleboy/scp-action@master with: source: build-root.tar.gz target: ${{ env.APP_DIR }} - host: ${{ env.DEV_HOST }} + host: ${{ env.DEV_HOST_SG_1 }} username: ${{ env.DEV_USER }} key: ${{ secrets.SSH_SECRET }} debug: true @@ -54,7 +59,7 @@ jobs: with: source: build-server.tar.gz target: ${{ env.APP_DIR }} - host: ${{ env.DEV_HOST }} + host: ${{ env.DEV_HOST_SG_1 }} username: ${{ env.DEV_USER }} key: ${{ secrets.SSH_SECRET }} - name: Upload build-web.tar.gz @@ -62,17 +67,17 @@ jobs: with: source: build-web.tar.gz target: ${{ env.APP_DIR }} - host: ${{ env.DEV_HOST }} + host: ${{ env.DEV_HOST_SG_1 }} username: ${{ env.DEV_USER }} key: ${{ secrets.SSH_SECRET }} - # Upload to GER + # Upload to SG_2 - name: Upload build-root.tar.gz uses: appleboy/scp-action@master with: source: build-root.tar.gz target: ${{ env.APP_DIR }} - host: ${{ env.DEV_HOST_1 }} + host: ${{ env.DEV_HOST_SG_2 }} username: ${{ env.DEV_USER }} key: ${{ secrets.SSH_SECRET }} debug: true @@ -81,7 +86,7 @@ jobs: with: source: build-server.tar.gz target: ${{ env.APP_DIR }} - host: ${{ env.DEV_HOST_1 }} + host: ${{ env.DEV_HOST_SG_2 }} username: ${{ env.DEV_USER }} key: ${{ secrets.SSH_SECRET }} - name: Upload build-web.tar.gz @@ -89,17 +94,18 @@ jobs: with: source: build-web.tar.gz target: ${{ env.APP_DIR }} - host: ${{ env.DEV_HOST_1 }} + host: ${{ env.DEV_HOST_SG_2 }} username: ${{ env.DEV_USER }} key: ${{ secrets.SSH_SECRET }} - # Upload to US + + # Upload to GE_1 - name: Upload build-root.tar.gz uses: appleboy/scp-action@master with: source: build-root.tar.gz target: ${{ env.APP_DIR }} - host: ${{ env.DEV_HOST_2 }} + host: ${{ env.DEV_HOST_GE_1 }} username: ${{ env.DEV_USER }} key: ${{ secrets.SSH_SECRET }} debug: true @@ -108,7 +114,7 @@ jobs: with: source: build-server.tar.gz target: ${{ env.APP_DIR }} - host: ${{ env.DEV_HOST_2 }} + host: ${{ env.DEV_HOST_GE_1 }} username: ${{ env.DEV_USER }} key: ${{ secrets.SSH_SECRET }} - name: Upload build-web.tar.gz @@ -116,16 +122,280 @@ jobs: with: source: build-web.tar.gz target: ${{ env.APP_DIR }} - host: ${{ env.DEV_HOST_2 }} + host: ${{ env.DEV_HOST_GE_1 }} username: ${{ env.DEV_USER }} key: ${{ secrets.SSH_SECRET }} - # Deployment SGP + # Upload to GE_2 + - name: Upload build-root.tar.gz + uses: appleboy/scp-action@master + with: + source: build-root.tar.gz + target: ${{ env.APP_DIR }} + host: ${{ env.DEV_HOST_GE_2 }} + username: ${{ env.DEV_USER }} + key: ${{ secrets.SSH_SECRET }} + debug: true + - name: Upload build-server.tar.gz + uses: appleboy/scp-action@master + with: + source: build-server.tar.gz + target: ${{ env.APP_DIR }} + host: ${{ env.DEV_HOST_GE_2 }} + username: ${{ env.DEV_USER }} + key: ${{ secrets.SSH_SECRET }} + - name: Upload build-web.tar.gz + uses: appleboy/scp-action@master + with: + source: build-web.tar.gz + target: ${{ env.APP_DIR }} + host: ${{ env.DEV_HOST_GE_2 }} + username: ${{ env.DEV_USER }} + key: ${{ secrets.SSH_SECRET }} + + # Upload to GE_3 + - name: Upload build-root.tar.gz + uses: appleboy/scp-action@master + with: + source: build-root.tar.gz + target: ${{ env.APP_DIR }} + host: ${{ env.DEV_HOST_GE_3 }} + username: ${{ env.DEV_USER }} + key: ${{ secrets.SSH_SECRET }} + debug: true + - name: Upload build-server.tar.gz + uses: appleboy/scp-action@master + with: + source: build-server.tar.gz + target: ${{ env.APP_DIR }} + host: ${{ env.DEV_HOST_GE_3 }} + username: ${{ env.DEV_USER }} + key: ${{ secrets.SSH_SECRET }} + - name: Upload build-web.tar.gz + uses: appleboy/scp-action@master + with: + source: build-web.tar.gz + target: ${{ env.APP_DIR }} + host: ${{ env.DEV_HOST_GE_3 }} + username: ${{ env.DEV_USER }} + key: ${{ secrets.SSH_SECRET }} + + + # Upload to US_1 + - name: Upload build-root.tar.gz + uses: appleboy/scp-action@master + with: + source: build-root.tar.gz + target: ${{ env.APP_DIR }} + host: ${{ env.DEV_HOST_US_1 }} + username: ${{ env.DEV_USER }} + key: ${{ secrets.SSH_SECRET }} + debug: true + - name: Upload build-server.tar.gz + uses: appleboy/scp-action@master + with: + source: build-server.tar.gz + target: ${{ env.APP_DIR }} + host: ${{ env.DEV_HOST_US_1 }} + username: ${{ env.DEV_USER }} + key: ${{ secrets.SSH_SECRET }} + - name: Upload build-web.tar.gz + uses: appleboy/scp-action@master + with: + source: build-web.tar.gz + target: ${{ env.APP_DIR }} + host: ${{ env.DEV_HOST_US_1 }} + username: ${{ env.DEV_USER }} + key: ${{ secrets.SSH_SECRET }} + + # Upload to US_2 + - name: Upload build-root.tar.gz + uses: appleboy/scp-action@master + with: + source: build-root.tar.gz + target: ${{ env.APP_DIR }} + host: ${{ env.DEV_HOST_US_2 }} + username: ${{ env.DEV_USER }} + key: ${{ secrets.SSH_SECRET }} + debug: true + - name: Upload build-server.tar.gz + uses: appleboy/scp-action@master + with: + source: build-server.tar.gz + target: ${{ env.APP_DIR }} + host: ${{ env.DEV_HOST_US_2 }} + username: ${{ env.DEV_USER }} + key: ${{ secrets.SSH_SECRET }} + - name: Upload build-web.tar.gz + uses: appleboy/scp-action@master + with: + source: build-web.tar.gz + target: ${{ env.APP_DIR }} + host: ${{ env.DEV_HOST_US_2 }} + username: ${{ env.DEV_USER }} + key: ${{ secrets.SSH_SECRET }} + + # Upload to US_3 + - name: Upload build-root.tar.gz + uses: appleboy/scp-action@master + with: + source: build-root.tar.gz + target: ${{ env.APP_DIR }} + host: ${{ env.DEV_HOST_US_3 }} + username: ${{ env.DEV_USER }} + key: ${{ secrets.SSH_SECRET }} + debug: true + - name: Upload build-server.tar.gz + uses: appleboy/scp-action@master + with: + source: build-server.tar.gz + target: ${{ env.APP_DIR }} + host: ${{ env.DEV_HOST_US_3 }} + username: ${{ env.DEV_USER }} + key: ${{ secrets.SSH_SECRET }} + - name: Upload build-web.tar.gz + uses: appleboy/scp-action@master + with: + source: build-web.tar.gz + target: ${{ env.APP_DIR }} + host: ${{ env.DEV_HOST_US_3 }} + username: ${{ env.DEV_USER }} + key: ${{ secrets.SSH_SECRET }} + + + # Deployment SG_1 + - name: Extract build-root.tar.gz + uses: appleboy/ssh-action@master + with: + script: cd ${{ env.APP_DIR }} && rm -rf node_modules && tar -xzf build-root.tar.gz && rm -rf build-root.tar.gz + host: ${{ env.DEV_SG_1 }} + username: ${{ env.DEV_USER }} + key: ${{ secrets.SSH_SECRET }} + - name: Extract build-web.tar.gz + if: ${{ github.event_name == 'push' }} + uses: appleboy/ssh-action@master + with: + script: cd ${{ env.APP_DIR }}/web && rm -rf node_modules && rm -rf build && cd .. && tar -xzf build-web.tar.gz && rm -rf build-web.tar.gz + host: ${{ env.DEV_SG_1 }} + username: ${{ env.DEV_USER }} + key: ${{ secrets.SSH_SECRET }} + - name: Extract build-server.tar.gz + if: ${{ github.event_name == 'push' }} + uses: appleboy/ssh-action@master + with: + script: cd ${{ env.APP_DIR }}/server && rm -rf node_modules && rm -rf dist && cd .. && tar -xzf build-server.tar.gz && rm -rf build-server.tar.gz && git pull origin main --rebase && cd ${{ env.APP_DIR }} && /usr/local/bin/pm2 restart td + host: ${{ env.DEV_SG_1 }} + username: ${{ env.DEV_USER }} + key: ${{ secrets.SSH_SECRET }} + + # Deployment SG_2 + - name: Extract build-root.tar.gz + uses: appleboy/ssh-action@master + with: + script: cd ${{ env.APP_DIR }} && rm -rf node_modules && tar -xzf build-root.tar.gz && rm -rf build-root.tar.gz + host: ${{ env.DEV_SG_2 }} + username: ${{ env.DEV_USER }} + key: ${{ secrets.SSH_SECRET }} + - name: Extract build-web.tar.gz + if: ${{ github.event_name == 'push' }} + uses: appleboy/ssh-action@master + with: + script: cd ${{ env.APP_DIR }}/web && rm -rf node_modules && rm -rf build && cd .. && tar -xzf build-web.tar.gz && rm -rf build-web.tar.gz + host: ${{ env.DEV_SG_2 }} + username: ${{ env.DEV_USER }} + key: ${{ secrets.SSH_SECRET }} + - name: Extract build-server.tar.gz + if: ${{ github.event_name == 'push' }} + uses: appleboy/ssh-action@master + with: + script: cd ${{ env.APP_DIR }}/server && rm -rf node_modules && rm -rf dist && cd .. && tar -xzf build-server.tar.gz && rm -rf build-server.tar.gz && git pull origin main --rebase && cd ${{ env.APP_DIR }} && /usr/local/bin/pm2 restart td + host: ${{ env.DEV_SG_2 }} + username: ${{ env.DEV_USER }} + key: ${{ secrets.SSH_SECRET }} + + + # Deployment GE_1 + - name: Extract build-root.tar.gz + uses: appleboy/ssh-action@master + with: + script: cd ${{ env.APP_DIR }} && rm -rf node_modules && tar -xzf build-root.tar.gz && rm -rf build-root.tar.gz + host: ${{ env.DEV_HOST_GE_1 }} + username: ${{ env.DEV_USER }} + key: ${{ secrets.SSH_SECRET }} + - name: Extract build-web.tar.gz + if: ${{ github.event_name == 'push' }} + uses: appleboy/ssh-action@master + with: + script: cd ${{ env.APP_DIR }}/web && rm -rf node_modules && rm -rf build && cd .. && tar -xzf build-web.tar.gz && rm -rf build-web.tar.gz + host: ${{ env.DEV_HOST_GE_1 }} + username: ${{ env.DEV_USER }} + key: ${{ secrets.SSH_SECRET }} + - name: Extract build-server.tar.gz + if: ${{ github.event_name == 'push' }} + uses: appleboy/ssh-action@master + with: + script: cd ${{ env.APP_DIR }}/server && rm -rf node_modules && rm -rf dist && cd .. && tar -xzf build-server.tar.gz && rm -rf build-server.tar.gz && git pull origin main --rebase && cd ${{ env.APP_DIR }} && /usr/local/bin/pm2 restart td + host: ${{ env.DEV_HOST_GE_1 }} + username: ${{ env.DEV_USER }} + key: ${{ secrets.SSH_SECRET }} + + # Deployment GE_2 + - name: Extract build-root.tar.gz + uses: appleboy/ssh-action@master + with: + script: cd ${{ env.APP_DIR }} && rm -rf node_modules && tar -xzf build-root.tar.gz && rm -rf build-root.tar.gz + host: ${{ env.DEV_HOST_GE_2 }} + username: ${{ env.DEV_USER }} + key: ${{ secrets.SSH_SECRET }} + - name: Extract build-web.tar.gz + if: ${{ github.event_name == 'push' }} + uses: appleboy/ssh-action@master + with: + script: cd ${{ env.APP_DIR }}/web && rm -rf node_modules && rm -rf build && cd .. && tar -xzf build-web.tar.gz && rm -rf build-web.tar.gz + host: ${{ env.DEV_HOST_GE_2 }} + username: ${{ env.DEV_USER }} + key: ${{ secrets.SSH_SECRET }} + - name: Extract build-server.tar.gz + if: ${{ github.event_name == 'push' }} + uses: appleboy/ssh-action@master + with: + script: cd ${{ env.APP_DIR }}/server && rm -rf node_modules && rm -rf dist && cd .. && tar -xzf build-server.tar.gz && rm -rf build-server.tar.gz && git pull origin main --rebase && cd ${{ env.APP_DIR }} && /usr/local/bin/pm2 restart td + host: ${{ env.DEV_HOST_GE_2 }} + username: ${{ env.DEV_USER }} + key: ${{ secrets.SSH_SECRET }} + + # Deployment GE_3 + - name: Extract build-root.tar.gz + uses: appleboy/ssh-action@master + with: + script: cd ${{ env.APP_DIR }} && rm -rf node_modules && tar -xzf build-root.tar.gz && rm -rf build-root.tar.gz + host: ${{ env.DEV_HOST_GE_3 }} + username: ${{ env.DEV_USER }} + key: ${{ secrets.SSH_SECRET }} + - name: Extract build-web.tar.gz + if: ${{ github.event_name == 'push' }} + uses: appleboy/ssh-action@master + with: + script: cd ${{ env.APP_DIR }}/web && rm -rf node_modules && rm -rf build && cd .. && tar -xzf build-web.tar.gz && rm -rf build-web.tar.gz + host: ${{ env.DEV_HOST_GE_3 }} + username: ${{ env.DEV_USER }} + key: ${{ secrets.SSH_SECRET }} + - name: Extract build-server.tar.gz + if: ${{ github.event_name == 'push' }} + uses: appleboy/ssh-action@master + with: + script: cd ${{ env.APP_DIR }}/server && rm -rf node_modules && rm -rf dist && cd .. && tar -xzf build-server.tar.gz && rm -rf build-server.tar.gz && git pull origin main --rebase && cd ${{ env.APP_DIR }} && /usr/local/bin/pm2 restart td + host: ${{ env.DEV_HOST_GE_3 }} + username: ${{ env.DEV_USER }} + key: ${{ secrets.SSH_SECRET }} + + + # Deployment US_1 - name: Extract build-root.tar.gz uses: appleboy/ssh-action@master with: script: cd ${{ env.APP_DIR }} && rm -rf node_modules && tar -xzf build-root.tar.gz && rm -rf build-root.tar.gz - host: ${{ env.DEV_HOST }} + host: ${{ env.DEV_HOST_US_1 }} username: ${{ env.DEV_USER }} key: ${{ secrets.SSH_SECRET }} - name: Extract build-web.tar.gz @@ -133,7 +403,7 @@ jobs: uses: appleboy/ssh-action@master with: script: cd ${{ env.APP_DIR }}/web && rm -rf node_modules && rm -rf build && cd .. && tar -xzf build-web.tar.gz && rm -rf build-web.tar.gz - host: ${{ env.DEV_HOST }} + host: ${{ env.DEV_HOST_US_1 }} username: ${{ env.DEV_USER }} key: ${{ secrets.SSH_SECRET }} - name: Extract build-server.tar.gz @@ -141,16 +411,16 @@ jobs: uses: appleboy/ssh-action@master with: script: cd ${{ env.APP_DIR }}/server && rm -rf node_modules && rm -rf dist && cd .. && tar -xzf build-server.tar.gz && rm -rf build-server.tar.gz && git pull origin main --rebase && cd ${{ env.APP_DIR }} && /usr/local/bin/pm2 restart td - host: ${{ env.DEV_HOST }} + host: ${{ env.DEV_HOST_US_1 }} username: ${{ env.DEV_USER }} key: ${{ secrets.SSH_SECRET }} - # Deployment GER + # Deployment US_2 - name: Extract build-root.tar.gz uses: appleboy/ssh-action@master with: script: cd ${{ env.APP_DIR }} && rm -rf node_modules && tar -xzf build-root.tar.gz && rm -rf build-root.tar.gz - host: ${{ env.DEV_HOST_1 }} + host: ${{ env.DEV_HOST_US_2 }} username: ${{ env.DEV_USER }} key: ${{ secrets.SSH_SECRET }} - name: Extract build-web.tar.gz @@ -158,7 +428,7 @@ jobs: uses: appleboy/ssh-action@master with: script: cd ${{ env.APP_DIR }}/web && rm -rf node_modules && rm -rf build && cd .. && tar -xzf build-web.tar.gz && rm -rf build-web.tar.gz - host: ${{ env.DEV_HOST_1 }} + host: ${{ env.DEV_HOST_US_2 }} username: ${{ env.DEV_USER }} key: ${{ secrets.SSH_SECRET }} - name: Extract build-server.tar.gz @@ -166,16 +436,16 @@ jobs: uses: appleboy/ssh-action@master with: script: cd ${{ env.APP_DIR }}/server && rm -rf node_modules && rm -rf dist && cd .. && tar -xzf build-server.tar.gz && rm -rf build-server.tar.gz && git pull origin main --rebase && cd ${{ env.APP_DIR }} && /usr/local/bin/pm2 restart td - host: ${{ env.DEV_HOST_1 }} + host: ${{ env.DEV_HOST_US_2 }} username: ${{ env.DEV_USER }} key: ${{ secrets.SSH_SECRET }} - # Deployment US + # Deployment US_3 - name: Extract build-root.tar.gz uses: appleboy/ssh-action@master with: script: cd ${{ env.APP_DIR }} && rm -rf node_modules && tar -xzf build-root.tar.gz && rm -rf build-root.tar.gz - host: ${{ env.DEV_HOST_2 }} + host: ${{ env.DEV_HOST_US_3 }} username: ${{ env.DEV_USER }} key: ${{ secrets.SSH_SECRET }} - name: Extract build-web.tar.gz @@ -183,7 +453,7 @@ jobs: uses: appleboy/ssh-action@master with: script: cd ${{ env.APP_DIR }}/web && rm -rf node_modules && rm -rf build && cd .. && tar -xzf build-web.tar.gz && rm -rf build-web.tar.gz - host: ${{ env.DEV_HOST_2 }} + host: ${{ env.DEV_HOST_US_3 }} username: ${{ env.DEV_USER }} key: ${{ secrets.SSH_SECRET }} - name: Extract build-server.tar.gz @@ -191,7 +461,7 @@ jobs: uses: appleboy/ssh-action@master with: script: cd ${{ env.APP_DIR }}/server && rm -rf node_modules && rm -rf dist && cd .. && tar -xzf build-server.tar.gz && rm -rf build-server.tar.gz && git pull origin main --rebase && cd ${{ env.APP_DIR }} && /usr/local/bin/pm2 restart td - host: ${{ env.DEV_HOST_2 }} + host: ${{ env.DEV_HOST_US_3 }} username: ${{ env.DEV_USER }} key: ${{ secrets.SSH_SECRET }} diff --git a/README.md b/README.md index eab8b9af1..09f442fa7 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ This is the open source project of Google Drive/OneDrive/iCloud/Dropbox alternat | PAYPAL_CLIENT_ID | yes | Client ID for PayPal subscription | | PAYPAL_CLIENT_SECRET | yes | Client secret for PayPal subscription | | PAYPAL_PLAN_PREMIUM_ID | yes | Product ID for premium plan | - | REDIS_URI | yes | Cache some responses from external services | + | REDIS_URI | no | Cache some responses from external services | | UTILS_API_KEY | yes | Token key for make all servers communicate | - Web variables diff --git a/server/src/api/v1/Contact.ts b/server/src/api/v1/Contact.ts index 7d64af6d9..a47dd9898 100644 --- a/server/src/api/v1/Contact.ts +++ b/server/src/api/v1/Contact.ts @@ -1,5 +1,6 @@ import axios from 'axios' import { Request, Response } from 'express' +import { Users } from '../../model/entities/Users' import { Endpoint } from '../base/Endpoint' @Endpoint.API() @@ -8,9 +9,10 @@ export class Contact { @Endpoint.POST() public async send(req: Request, res: Response): Promise { const { from, message } = req.body + const user = await Users.createQueryBuilder('users').select(['users.subscription_id', 'users.midtrans_id', 'users.plan']).where({ username: from }).getOne() await axios.post(`https://api.telegram.org/bot${process.env.TG_BOT_TOKEN}/sendMessage`, { chat_id: process.env.TG_BOT_OWNER_ID, - text: `🛎 @${from} wants to contact you!\n\n${message}` + text: `🛎 @${from} wants to contact you!\n\n${message}\n\nfrom: ${req.headers['authority'] || req.headers.origin}${user ? `\nplan: ${user.plan}${user.subscription_id ? `\npaypal: ${user.subscription_id}` : ''}${user.midtrans_id ? `\nmidtrans: ${user.midtrans_id}` : ''}` : ''}` }) return res.send({ success: true }) } diff --git a/server/src/service/Cache.ts b/server/src/service/Cache.ts index 058953d9a..56489ffa0 100644 --- a/server/src/service/Cache.ts +++ b/server/src/service/Cache.ts @@ -5,9 +5,6 @@ export class Redis { private redis: IOredis private constructor() { - if (!process.env.REDIS_URI) { - throw new Error('REDIS_URI is not defined') - } this.redis = new IORedis(process.env.REDIS_URI) } @@ -52,4 +49,4 @@ export class Redis { await this.set(key, data, ex) return data } -} \ No newline at end of file +} diff --git a/web/public/index.html b/web/public/index.html index 1b0e35f9d..a9d774df2 100644 --- a/web/public/index.html +++ b/web/public/index.html @@ -31,7 +31,7 @@ Learn how to configure a non-root public URL by running `npm run build`. --> TeleDrive - The Free Unlimited Cloud Storage - +