From f0782a63b5212f7af4b57e92e0fcd752df42c90f Mon Sep 17 00:00:00 2001 From: Viswanath <65813999+nenokkadine@users.noreply.github.com> Date: Sun, 20 Jun 2021 11:10:27 +0530 Subject: [PATCH] Update Dependencies (#12) * Update Workflows - Node Server Will run on UDS - Remove unused deps in Dockerfile - Remove Base image Workflow * Update Dependencies * Fix Docker Release * Fix * Use Build Push Action --- .github/workflows/baseimage-build.yml | 22 ---------------- .github/workflows/release-publish.yml | 38 +++++++++++++++++++++++---- baseimage/Dockerfile | 4 +-- heroku/start.sh | 4 +-- src/package.json | 19 +++++--------- src/server.js | 12 ++++++--- 6 files changed, 52 insertions(+), 47 deletions(-) delete mode 100644 .github/workflows/baseimage-build.yml diff --git a/.github/workflows/baseimage-build.yml b/.github/workflows/baseimage-build.yml deleted file mode 100644 index 4f196ff..0000000 --- a/.github/workflows/baseimage-build.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: GDUtils Base Image - -on: workflow_dispatch - -env: - IMAGE: ghcr.io/nenokkadine/gdutils - -jobs: - push: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - - name: Login to ghcr.io - run: docker login https://ghcr.io -u token -p ${{ secrets.GH_TOKEN }} - - - name: Build and Push image - run: | - docker build . -f baseimage/Dockerfile -t ${{ env.IMAGE }}:latest - echo "Pushing" - docker push ${{ env.IMAGE }}:latest \ No newline at end of file diff --git a/.github/workflows/release-publish.yml b/.github/workflows/release-publish.yml index f39b643..3d42769 100644 --- a/.github/workflows/release-publish.yml +++ b/.github/workflows/release-publish.yml @@ -3,10 +3,10 @@ name: Release on: push: tags: - - "v*" + - "v*.*.*" jobs: - Builds: + ReleaseAssets: runs-on: ubuntu-latest steps: @@ -14,9 +14,12 @@ jobs: id: get_version run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} - uses: actions/checkout@v2 - - run: docker build . -f builder/Dockerfile -t builder:latest - - run: docker run --name=gdutils --rm -dit builder:latest bash - - run: docker cp gdutils:/builder/ ./ + - name: Docker Build + run: docker build . -f builder/Dockerfile -t builder:latest + - name: Run the Docker image + run: docker run --name=gdutils --rm -dit builder:latest bash + - name: Copy Built files + run: docker cp gdutils:/builder/ ./ - name: Compress Build Outputs run: | cd builder @@ -35,3 +38,28 @@ jobs: name: GD-Utils Build ${{ steps.get_version.outputs.VERSION }} files: | builder/build/gdutils.tar.gz + DockerImage: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Docker meta + id: meta + uses: docker/metadata-action@v3 + with: + images: ghcr.io/nenokkadine/gdutils + - name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: token + password: ${{ secrets.GH_TOKEN }} + - name: Build and push + uses: docker/build-push-action@v2 + with: + context: . + file: baseimage/Dockerfile + platforms: linux/amd64 + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file diff --git a/baseimage/Dockerfile b/baseimage/Dockerfile index e16584c..5eb9c55 100644 --- a/baseimage/Dockerfile +++ b/baseimage/Dockerfile @@ -10,8 +10,6 @@ RUN apk update && \ tar \ unzip \ xz \ - neofetch \ - htop \ bash && \ - mkdir /gdutils + mkdir /gdutils && chmod 777 /gdutils WORKDIR /gdutils diff --git a/heroku/start.sh b/heroku/start.sh index 3ac0274..72b87d7 100644 --- a/heroku/start.sh +++ b/heroku/start.sh @@ -35,9 +35,9 @@ node server.js & # HTTPS Auth if [[ -n "$HTTP_USER" && -n "$HTTP_PASS" ]]; then - wget -qO- https://gist.github.com/nenokkadine/5db0fff9216fcedc0dd5862d0a5ab864/raw/95cabcaaf776e47ebb1990b2583f443171cf742a/caddyauth | sed -e "s/\$HTTP_USER/$HTTP_USER/g" -e "s/\$HASHPASS/$(caddy hash-password --plaintext $HTTP_PASS)/g" > /Caddyfile + wget -qO- https://gist.github.com/nenokkadine/5db0fff9216fcedc0dd5862d0a5ab864/raw/4dd7e7b8edb691fc77a78cc174e88baab4ff073c/caddyauth | sed -e "s/\$HTTP_USER/$HTTP_USER/g" -e "s/\$HASHPASS/$(caddy hash-password --plaintext $HTTP_PASS)/g" > /Caddyfile else - wget -q https://gist.github.com/nenokkadine/5db0fff9216fcedc0dd5862d0a5ab864/raw/95cabcaaf776e47ebb1990b2583f443171cf742a/caddynoauth -O /Caddyfile + wget -q https://gist.github.com/nenokkadine/5db0fff9216fcedc0dd5862d0a5ab864/raw/4dd7e7b8edb691fc77a78cc174e88baab4ff073c/caddynoauth -O /Caddyfile fi #Terminal over Web diff --git a/src/package.json b/src/package.json index 8f47e3c..7c28cce 100644 --- a/src/package.json +++ b/src/package.json @@ -1,25 +1,20 @@ { - "name": "gd-utils", - "version": "1.0.1", - "description": "google drive utils", + "name": "GD-Utils", + "version": "1.0.2", + "description": "Google Drive Utils", "repository": "iwestlin/gd-utils", - "main": "src/gd.js", - "scripts": { - "start": "https_proxy='http://127.0.0.1:1086' nodemon server.js", - "test": "echo \"Error: no test specified\" && exit 1" - }, "keywords": [], "author": "viegg", "license": "ISC", "dependencies": { "@koa/router": "^10.0.0", "@viegg/axios": "^1.0.0", - "better-sqlite3": "^7.1.5", + "better-sqlite3": "^7.4.1", "bytes": "^3.1.0", "cli-table3": "^0.6.0", "colors": "^1.4.0", - "dayjs": "^1.10.4", - "gtoken": "^5.2.1", + "dayjs": "^1.10.5", + "gtoken": "^5.3.0", "html-escaper": "^3.0.3", "https-proxy-agent": "^5.0.0", "koa": "^2.13.1", @@ -28,6 +23,6 @@ "prompts": "^2.4.1", "proxy-agent": "^4.0.1", "signal-exit": "^3.0.3", - "yargs": "^16.2.0" + "yargs": "^17.0.1" } } diff --git a/src/server.js b/src/server.js index 10467db..0f3428a 100644 --- a/src/server.js +++ b/src/server.js @@ -2,6 +2,7 @@ const dayjs = require('dayjs') const Koa = require('koa') const bodyParser = require('koa-bodyparser') const router = require('./src/router') +var fs = require('fs'); const app = new Koa() app.proxy = true @@ -11,8 +12,13 @@ app.use(bodyParser()) app.use(router.routes()) app.use(router.allowedMethods()) -const PRT = 23333 -app.listen(PRT, '0.0.0.0', console.log('http://127.0.0.1:' + PRT)) +const G_SOCK = "/usr/gdutils.sock" + +if (fs.existsSync(G_SOCK)) { + fs.unlinkSync(G_SOCK) +} + +app.listen(G_SOCK, '0.0.0.0') async function catcher (ctx, next) { try { @@ -22,4 +28,4 @@ async function catcher (ctx, next) { ctx.status = 500 ctx.body = e.message } -} +} \ No newline at end of file