diff --git a/.github/workflows/build-app-beta.yaml b/.github/workflows/build-app-beta.yaml deleted file mode 100644 index 78ec0e614c..0000000000 --- a/.github/workflows/build-app-beta.yaml +++ /dev/null @@ -1,109 +0,0 @@ -name: Electron app BETA - -on: - push: - tags: - - 'v[0-9]+.[0-9]+.[0-9]+-beta.[0-9]+' - -jobs: - build: - runs-on: ${{ matrix.os }} - - strategy: - fail-fast: false - matrix: - os: [macos-12, windows-2022, ubuntu-22.04] - # os: [macOS-10.15] - - steps: - - name: Context - env: - GITHUB_CONTEXT: ${{ toJson(github) }} - run: echo "$GITHUB_CONTEXT" - - uses: actions/checkout@v2 - with: - fetch-depth: 1 - - name: Use Node.js 16.x - uses: actions/setup-node@v1 - with: - node-version: 16.x - - name: yarn adjustPackageJson - run: | - yarn adjustPackageJson - - name: yarn set timeout - run: | - yarn config set network-timeout 100000 - - name: yarn install - run: | - yarn install - - name: setCurrentVersion - run: | - yarn setCurrentVersion - - name: fillNativeModulesElectron - run: | - yarn fillNativeModulesElectron - - name: fillPackagedPlugins - run: | - yarn fillPackagedPlugins - - name: Install Snapcraft - if: matrix.os == 'ubuntu-22.04' - uses: samuelmeuli/action-snapcraft@v1 - - name: Publish - run: | - yarn run build:app - env: - GH_TOKEN: ${{ secrets.GH_TOKEN }} # token for electron publish - - WIN_CSC_LINK: ${{ secrets.WINCERT_2025 }} - WIN_CSC_KEY_PASSWORD: ${{ secrets.WINCERT_2025_PASSWORD }} - # WIN_CSC_LINK: ${{ secrets.WINCERT_CERTIFICATE }} - # WIN_CSC_KEY_PASSWORD: ${{ secrets.WINCERT_PASSWORD }} - - CSC_LINK: ${{ secrets.APPLECERT_CERTIFICATE }} - CSC_KEY_PASSWORD: ${{ secrets.APPLECERT_PASSWORD }} - - APPLE_ID: ${{ secrets.APPLE_ID }} - APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }} - - - name: publishSnap - if: matrix.os == 'ubuntu-22.04' - run: | - snapcraft upload --release=beta app/dist/*.snap - env: - SNAPCRAFT_STORE_CREDENTIALS: ${{secrets.SNAPCRAFT_LOGIN}} - - - name: Copy artifacts - run: | - mkdir artifacts - - cp app/dist/*.deb artifacts/dbgate-beta.deb || true - cp app/dist/*x86*.AppImage artifacts/dbgate-beta.AppImage || true - cp app/dist/*arm64*.AppImage artifacts/dbgate-beta-arm64.AppImage || true - cp app/dist/*armv7l*.AppImage artifacts/dbgate-beta-armv7l.AppImage || true - cp app/dist/*win*.exe artifacts/dbgate-beta.exe || true - cp app/dist/*win_x64.zip artifacts/dbgate-windows-beta.zip || true - cp app/dist/*win_arm64.zip artifacts/dbgate-windows-beta-arm64.zip || true - cp app/dist/*-mac_x64.dmg artifacts/dbgate-beta.dmg || true - cp app/dist/*-mac_arm64.dmg artifacts/dbgate-beta-arm64.dmg || true - - mv app/dist/*.exe artifacts/ || true - mv app/dist/*.zip artifacts/ || true - mv app/dist/*.AppImage artifacts/ || true - mv app/dist/*.deb artifacts/ || true - mv app/dist/*.snap artifacts/ || true - mv app/dist/*.dmg artifacts/ || true - - - name: Upload artifacts - uses: actions/upload-artifact@v1 - with: - name: ${{ matrix.os }} - path: artifacts - - - name: Release - uses: softprops/action-gh-release@v1 - if: startsWith(github.ref, 'refs/tags/') - with: - files: 'artifacts/**' - prerelease: true - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/build-app.yaml b/.github/workflows/build-app.yaml deleted file mode 100644 index 980e612a4f..0000000000 --- a/.github/workflows/build-app.yaml +++ /dev/null @@ -1,169 +0,0 @@ -name: Electron app - -on: - push: - tags: - - 'v[0-9]+.[0-9]+.[0-9]+' - # - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 - - # branches: - # - production - -jobs: - build: - runs-on: ${{ matrix.os }} - - strategy: - fail-fast: false - matrix: - # os: [ubuntu-22.04, windows-2016] - os: [macos-12, windows-2022, ubuntu-22.04] - - steps: - - name: Context - env: - GITHUB_CONTEXT: ${{ toJson(github) }} - run: echo "$GITHUB_CONTEXT" - - uses: actions/checkout@v2 - with: - fetch-depth: 1 - - name: Use Node.js 16.x - uses: actions/setup-node@v1 - with: - node-version: 16.x - - name: yarn adjustPackageJson - run: | - yarn adjustPackageJson - - name: yarn set timeout - run: | - yarn config set network-timeout 100000 - - name: yarn install - run: | - # yarn --version - # yarn config set network-timeout 300000 - yarn install - - name: setCurrentVersion - run: | - yarn setCurrentVersion - - name: fillNativeModulesElectron - run: | - yarn fillNativeModulesElectron - - name: fillPackagedPlugins - run: | - yarn fillPackagedPlugins - - name: Install Snapcraft - if: matrix.os == 'ubuntu-22.04' - uses: samuelmeuli/action-snapcraft@v1 - - name: Publish - run: | - yarn run build:app - env: - GH_TOKEN: ${{ secrets.GH_TOKEN }} # token for electron publish - - WIN_CSC_LINK: ${{ secrets.WINCERT_2025 }} - WIN_CSC_KEY_PASSWORD: ${{ secrets.WINCERT_2025_PASSWORD }} - # WIN_CSC_LINK: ${{ secrets.WINCERT_CERTIFICATE }} - # WIN_CSC_KEY_PASSWORD: ${{ secrets.WINCERT_PASSWORD }} - - CSC_LINK: ${{ secrets.APPLECERT_CERTIFICATE }} - CSC_KEY_PASSWORD: ${{ secrets.APPLECERT_PASSWORD }} - - APPLE_ID: ${{ secrets.APPLE_ID }} - APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }} - - - name: generatePadFile - run: | - yarn generatePadFile - - - name: publishSnap - if: matrix.os == 'ubuntu-22.04' - run: | - snapcraft upload --release=stable app/dist/*.snap - env: - SNAPCRAFT_STORE_CREDENTIALS: ${{secrets.SNAPCRAFT_LOGIN}} - - - name: Copy artifacts - run: | - mkdir artifacts - - cp app/dist/*.deb artifacts/dbgate-latest.deb || true - cp app/dist/*x86*.AppImage artifacts/dbgate-latest.AppImage || true - cp app/dist/*arm64*.AppImage artifacts/dbgate-latest-arm64.AppImage || true - cp app/dist/*armv7l*.AppImage artifacts/dbgate-latest-armv7l.AppImage || true - cp app/dist/*.exe artifacts/dbgate-latest.exe || true - cp app/dist/*win_x64.zip artifacts/dbgate-windows-latest.zip || true - cp app/dist/*win_arm64.zip artifacts/dbgate-windows-latest-arm64.zip || true - cp app/dist/*-mac_universal.dmg artifacts/dbgate-latest.dmg || true - cp app/dist/*-mac_x64.dmg artifacts/dbgate-latest-x64.dmg || true - - mv app/dist/*.exe artifacts/ || true - mv app/dist/*.zip artifacts/ || true - mv app/dist/*.AppImage artifacts/ || true - mv app/dist/*.deb artifacts/ || true - mv app/dist/*.dmg artifacts/ || true - mv app/dist/*.snap artifacts/dbgate-latest.snap || true - - # - name: Copy artifacts Linux, MacOs - # if: matrix.os != 'windows-2016' - # run: | - # mkdir artifacts - - # cp app/dist/*.AppImage artifacts/ || true - # cp app/dist/*.dmg artifacts/ || true - # cp app/dist/*.deb artifacts/ || true - - # mv app/dist/*.deb artifacts/dbgate-linux.deb || true - # mv app/dist/*.AppImage artifacts/dbgate-linux.AppImage || true - # mv app/dist/*.dmg artifacts/dbgate-mac.dmg || true - - # - name: Copy artifacts Win - # if: matrix.os == 'windows-2016' - # run: | - # mkdir artifacts - - # cp app/dist/*.exe artifacts/ || true - - # mv app/dist/*.exe artifacts/dbgate-windows.exe - - # mv app/dist/latest.yml artifacts/latest.yml || true - - - name: Copy latest.yml (windows) - if: matrix.os == 'windows-2022' - run: | - mv app/dist/latest.yml artifacts/latest.yml || true - mv app/dist/dbgate-pad.xml artifacts/ || true - - - name: Copy latest-linux.yml - if: matrix.os == 'ubuntu-22.04' - run: | - mv app/dist/latest-linux.yml artifacts/latest-linux.yml || true - - - name: Copy latest-mac.yml - if: matrix.os == 'macos-12' - run: | - mv app/dist/latest-mac.yml artifacts/latest-mac.yml || true - - - name: Upload artifacts - uses: actions/upload-artifact@v1 - with: - name: ${{ matrix.os }} - path: artifacts - - - name: Release - uses: softprops/action-gh-release@v1 - if: startsWith(github.ref, 'refs/tags/') - with: - files: 'artifacts/**' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - # - name: Create Release - # id: create_release - # uses: actions/create-release@v1 - # env: - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # with: - # tag_name: ${{ github.ref }} - # release_name: Release ${{ github.ref }} - # draft: false - # prerelease: false diff --git a/.github/workflows/build-docker.yaml b/.github/workflows/build-docker.yaml index 1559acd380..0cb9f0ff76 100644 --- a/.github/workflows/build-docker.yaml +++ b/.github/workflows/build-docker.yaml @@ -1,15 +1,9 @@ name: Docker image -on: - push: - tags: - - 'v[0-9]+.[0-9]+.[0-9]+' - - 'v[0-9]+.[0-9]+.[0-9]+-beta.[0-9]+' - - 'v[0-9]+.[0-9]+.[0-9]+-docker.[0-9]+' +on: [ push, pull_request ] jobs: build: - runs-on: ${{ matrix.os }} strategy: @@ -30,7 +24,7 @@ jobs: uses: docker/metadata-action@v4 with: images: | - dbgate/dbgate + casbin/dbgate flavor: | latest=false tags: | @@ -44,7 +38,7 @@ jobs: uses: docker/metadata-action@v4 with: images: | - dbgate/dbgate + casbin/dbgate flavor: | latest=false tags: | @@ -74,10 +68,11 @@ jobs: - name: Login to DockerHub uses: docker/login-action@v2 with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} - name: Build and push + if: github.repository == 'casvisor/dbgate' && github.event_name == 'push' uses: docker/build-push-action@v3 with: push: true @@ -86,6 +81,7 @@ jobs: platforms: linux/amd64,linux/arm64,linux/arm/v7 - name: Build and push alpine + if: github.repository == 'casvisor/dbgate' && github.event_name == 'push' uses: docker/build-push-action@v3 with: push: true diff --git a/.github/workflows/build-npm.yaml b/.github/workflows/build-npm.yaml deleted file mode 100644 index bef46c85d3..0000000000 --- a/.github/workflows/build-npm.yaml +++ /dev/null @@ -1,150 +0,0 @@ -name: NPM packages - -# on: [push] - -on: - push: - tags: - - 'v[0-9]+.[0-9]+.[0-9]+' - - 'v[0-9]+.[0-9]+.[0-9]+-alpha.[0-9]+' - -# on: -# push: -# branches: -# - production - -jobs: - build: - - runs-on: ${{ matrix.os }} - - strategy: - matrix: - os: [ubuntu-22.04] - - steps: - - name: Context - env: - GITHUB_CONTEXT: ${{ toJson(github) }} - run: echo "$GITHUB_CONTEXT" - - uses: actions/checkout@v2 - with: - fetch-depth: 1 - - name: Use Node.js 16.x - uses: actions/setup-node@v1 - with: - node-version: 16.x - - - name: Configure NPM token - env: - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - run: | - npm config set '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}" - - - name: yarn install - run: | - yarn install - - - name: setCurrentVersion - run: | - yarn setCurrentVersion - - - name: Publish types - working-directory: packages/types - run: | - npm publish - - - name: Publish tools - working-directory: packages/tools - run: | - npm publish - - - name: Publish sqltree - working-directory: packages/sqltree - run: | - npm publish - - - name: Publish api - working-directory: packages/api - run: | - npm publish - - - name: Publish datalib - working-directory: packages/datalib - run: | - npm publish - - - name: Publish filterparser - working-directory: packages/filterparser - run: | - npm publish - - - name: Publish web - working-directory: packages/web - run: | - npm publish - - - name: Publish dbgate (obsolete) - working-directory: packages/dbgate - run: | - npm publish - - - name: Publish dbgate-serve - working-directory: packages/serve - run: | - npm publish - - - name: Publish dbmodel - working-directory: packages/dbmodel - run: | - npm publish - - - name: Publish dbgate-plugin-csv - working-directory: plugins/dbgate-plugin-csv - run: | - npm publish - - - name: Publish dbgate-plugin-xml - working-directory: plugins/dbgate-plugin-xml - run: | - npm publish - - - name: Publish dbgate-plugin-excel - working-directory: plugins/dbgate-plugin-excel - run: | - npm publish - - - name: Publish dbgate-plugin-mssql - working-directory: plugins/dbgate-plugin-mssql - run: | - npm publish - - - name: Publish dbgate-plugin-mysql - working-directory: plugins/dbgate-plugin-mysql - run: | - npm publish - - - name: Publish dbgate-plugin-mongo - working-directory: plugins/dbgate-plugin-mongo - run: | - npm publish - - - name: Publish dbgate-plugin-postgres - working-directory: plugins/dbgate-plugin-postgres - run: | - npm publish - - - name: Publish dbgate-plugin-sqlite - working-directory: plugins/dbgate-plugin-sqlite - run: | - npm publish - - - name: Publish dbgate-plugin-redis - working-directory: plugins/dbgate-plugin-redis - run: | - npm publish - - - name: Publish dbgate-plugin-oracle - working-directory: plugins/dbgate-plugin-oracle - run: | - npm publish diff --git a/docker-compose.yaml b/docker-compose.yaml index addc1da93b..ecc2fe1418 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -9,12 +9,12 @@ services: # image: dbgate/dbgate:beta restart: always ports: - - 3100:3000 + - "3100:3000" # volumes: # - /home/jena/dbgate-data:/root/dbgate-data volumes: - - dbgate-data:/root/.dbgate + - dbgate-data:/home/dbgate-docker/.dbgate # environment: # WEB_ROOT: /dbgate diff --git a/docker/Dockerfile b/docker/Dockerfile index 253df5d1fb..7acfe3e968 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -25,6 +25,6 @@ RUN ["chmod", "+x", "/home/dbgate-docker/entrypoint.sh"] WORKDIR /home/dbgate-docker EXPOSE 3000 -VOLUME /root/.dbgate +VOLUME /home/dbgate-docker/.dbgate CMD ["/home/dbgate-docker/entrypoint.sh"] diff --git a/docker/Dockerfile-alpine b/docker/Dockerfile-alpine index 742c602801..7c2e9985d7 100644 --- a/docker/Dockerfile-alpine +++ b/docker/Dockerfile-alpine @@ -12,6 +12,6 @@ RUN ["chmod", "+x", "/home/dbgate-docker/entrypoint.sh"] WORKDIR /home/dbgate-docker EXPOSE 3000 -VOLUME /root/.dbgate +VOLUME /home/dbgate-docker/.dbgate CMD ["/home/dbgate-docker/entrypoint.sh"] diff --git a/packages/api/.env b/packages/api/.env index 8a2d55b130..656a0421a1 100644 --- a/packages/api/.env +++ b/packages/api/.env @@ -1,7 +1,7 @@ DEVMODE=1 SHELL_SCRIPTING=1 DEVWEB=1 -runAsPortal=1 +RUN_AS_PORTAL=1 WORKSPACE_DIR=../../.dbgate # PERMISSIONS=~widgets/app,~widgets/plugins diff --git a/packages/api/src/controllers/config.js b/packages/api/src/controllers/config.js index 7811f68e52..04b49bbb7d 100644 --- a/packages/api/src/controllers/config.js +++ b/packages/api/src/controllers/config.js @@ -34,13 +34,13 @@ module.exports = { const permissions = login ? login.permissions : process.env.PERMISSIONS; return { - runAsPortal: !!connections.portalConnections || !!process.env.runAsPortal, + runAsPortal: !!connections.portalConnections || !!process.env.RUN_AS_PORTAL || platformInfo.isCasvisor, singleDbConnection: connections.singleDbConnection, singleConnection: connections.singleConnection, // hideAppEditor: !!process.env.HIDE_APP_EDITOR, allowShellConnection: platformInfo.allowShellConnection, allowShellScripting: platformInfo.allowShellScripting, - isDocker: platformInfo.isDocker, + isDocker: platformInfo.isDocker || platformInfo.isCasvisor, permissions, login, oauth: process.env.OAUTH_AUTH, diff --git a/packages/api/src/main.js b/packages/api/src/main.js index d9d81c61f9..6aae9fcaa5 100644 --- a/packages/api/src/main.js +++ b/packages/api/src/main.js @@ -57,7 +57,9 @@ function start() { app.use(cors()); - if (platformInfo.isDocker) { + if (platformInfo.isCasvisor) { + app.use(getExpressPath('/'), express.static('/home/casvisor/dbgate-docker/public')); + } else if(platformInfo.isDocker){ // server static files inside docker container app.use(getExpressPath('/'), express.static('/home/dbgate-docker/public')); } else if (platformInfo.isNpmDist) { diff --git a/packages/api/src/utility/directories.js b/packages/api/src/utility/directories.js index 3d1f4f516d..f912591859 100644 --- a/packages/api/src/utility/directories.js +++ b/packages/api/src/utility/directories.js @@ -32,6 +32,9 @@ function datadirCore() { if (processArgs.workspaceDir) { return processArgs.workspaceDir; } + if(platformInfo.isCasvisor){ + return path.join('/home/casvisor/dbgate-docker', '.dbgate'); + } return path.join(os.homedir(), '.dbgate'); } @@ -71,6 +74,9 @@ function packagedPluginsDir() { if (platformInfo.isDevMode) { return path.resolve(__dirname, '../../../../plugins'); } + if(platformInfo.isCasvisor){ + return path.join('/home/casvisor/dbgate-docker', 'plugins'); + } if (platformInfo.isDocker) { return '/home/dbgate-docker/plugins'; } diff --git a/packages/api/src/utility/platformInfo.js b/packages/api/src/utility/platformInfo.js index d6af1323af..78575b843e 100644 --- a/packages/api/src/utility/platformInfo.js +++ b/packages/api/src/utility/platformInfo.js @@ -12,6 +12,7 @@ const isDocker = fs.existsSync('/home/dbgate-docker/public'); const isDevMode = process.env.DEVMODE == '1'; const isNpmDist = !!global['IS_NPM_DIST']; const isForkedApi = processArgs.isForkedApi; +const isCasvisor = fs.existsSync('/home/casvisor/dbgate-docker'); // function moduleAvailable(name) { // try { @@ -27,6 +28,7 @@ const platformInfo = { isMac, isLinux, isDocker, + isCasvisor, isElectronBundle: isElectron() && !isDevMode, isForkedApi, isElectron: isElectron(),