From 1ae7c4af0abf9e9cbf5170f77ed41b07746270b5 Mon Sep 17 00:00:00 2001 From: Johannes Faltermeier Date: Thu, 2 Feb 2023 13:20:18 +0100 Subject: [PATCH 1/4] Create Browser Application and Dockerfile #75 * create a dedicated browser application * adapt product so that frontend code is useable from browser app as well * move electron:rebuild to laters stage to avoid conflicts between both applications * Create Dockerfile with Github Workflow and adapt Readme Signed-off-by: Johannes Faltermeier --- .github/workflows/publish-blueprint-img.yml | 34 +++++ README.md | 16 +++ applications/browser/package.json | 124 ++++++++++++++++++ applications/browser/resources/preload.html | 91 +++++++++++++ applications/browser/tsconfig.json | 12 ++ applications/browser/webpack.config.js | 17 +++ applications/electron/package.json | 5 +- browser.Dockerfile | 37 ++++++ package.json | 1 + .../theia-blueprint-product/package.json | 2 +- 10 files changed, 336 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/publish-blueprint-img.yml create mode 100644 applications/browser/package.json create mode 100644 applications/browser/resources/preload.html create mode 100644 applications/browser/tsconfig.json create mode 100644 applications/browser/webpack.config.js create mode 100644 browser.Dockerfile diff --git a/.github/workflows/publish-blueprint-img.yml b/.github/workflows/publish-blueprint-img.yml new file mode 100644 index 000000000..b0aedd8f1 --- /dev/null +++ b/.github/workflows/publish-blueprint-img.yml @@ -0,0 +1,34 @@ +name: Publish Blueprint Docker Image + +on: + workflow_dispatch: + inputs: + tag: + description: The image's tag + required: true + default: next + +jobs: + build: + name: Build and push blueprint image to Docker Hub + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Login to Docker Hub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@v2 + with: + context: . + file: browser.Dockerfile + push: true + tags: | + eclipsetheia/blueprint:${{ github.event.inputs.tag }} + eclipsetheia/blueprint:latest \ No newline at end of file diff --git a/README.md b/README.md index ca05110a6..5f339fd6d 100644 --- a/README.md +++ b/README.md @@ -95,3 +95,19 @@ yarn electron test The features in Eclipse Theia Blueprint are based on Theia and the included extensions/plugins. For bugs in Theia please consider opening an issue in the [Theia project on Github](https://github.com/eclipse-theia/theia/issues/new/choose). Eclipse Theia Blueprint only packages existing functionality into a product and installers for the product. If you believe there is a mistake in packaging, something needs to be added to the packaging or the installers do not work properly, please [open an issue on Github](https://github.com/eclipse-theia/theia-blueprint/issues/new/choose) to let us know. + +### Docker Build + +You can create a Docker Image for Blueprint with the following build command: + +```sh +docker build -t theia-blueprint -f browser.Dockerfile . +``` + +You may then run this with + +```sh +docker run -p=3000:3000 --rm theia-blueprint +``` + +and connect to diff --git a/applications/browser/package.json b/applications/browser/package.json new file mode 100644 index 000000000..0dcb2a3c7 --- /dev/null +++ b/applications/browser/package.json @@ -0,0 +1,124 @@ +{ + "private": true, + "name": "theia-blueprint-browser", + "description": "Eclipse Theia blueprint browser product", + "productName": "Theia Blueprint", + "version": "1.35.0", + "license": "EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0", + "author": "Eclipse Theia ", + "homepage": "https://github.com/eclipse-theia/theia-blueprint#readme", + "bugs": { + "url": "https://github.com/eclipse-theia/theia/issues" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/eclipse-theia/theia-blueprint.git" + }, + "engines": { + "yarn": ">=1.7.0 <2", + "node": ">=12.14.1" + }, + "theia": { + "frontend": { + "config": { + "applicationName": "Theia Blueprint", + "preferences": { + "toolbar.showToolbar": true, + "files.enableTrash": false + } + } + }, + "backend": { + "config": { + "startupTimeout": -1, + "resolveSystemPlugins": false + } + }, + "generator": { + "config": { + "preloadTemplate": "./resources/preload.html" + } + } + }, + "dependencies": { + "@theia/bulk-edit": "1.35.0", + "@theia/callhierarchy": "1.35.0", + "@theia/console": "1.35.0", + "@theia/core": "1.35.0", + "@theia/debug": "1.35.0", + "@theia/editor": "1.35.0", + "@theia/editor-preview": "1.35.0", + "@theia/external-terminal": "1.35.0", + "@theia/file-search": "1.35.0", + "@theia/filesystem": "1.35.0", + "@theia/getting-started": "1.35.0", + "@theia/git": "1.35.0", + "@theia/keymaps": "1.35.0", + "@theia/markers": "1.35.0", + "@theia/messages": "1.35.0", + "@theia/memory-inspector": "1.35.0", + "@theia/metrics": "1.35.0", + "@theia/mini-browser": "1.35.0", + "@theia/monaco": "1.35.0", + "@theia/navigator": "1.35.0", + "@theia/outline-view": "1.35.0", + "@theia/output": "1.35.0", + "@theia/plugin-dev": "1.35.0", + "@theia/plugin-ext": "1.35.0", + "@theia/plugin-ext-vscode": "1.35.0", + "@theia/preferences": "1.35.0", + "@theia/process": "1.35.0", + "@theia/property-view": "1.35.0", + "@theia/scm": "1.35.0", + "@theia/scm-extra": "1.35.0", + "@theia/search-in-workspace": "1.35.0", + "@theia/task": "1.35.0", + "@theia/terminal": "1.35.0", + "@theia/timeline": "1.35.0", + "@theia/toolbar": "1.35.0", + "@theia/typehierarchy": "1.35.0", + "@theia/userstorage": "1.35.0", + "@theia/variable-resolver": "1.35.0", + "@theia/vsx-registry": "1.35.0", + "@theia/workspace": "1.35.0", + "fs-extra": "^9.0.1", + "theia-blueprint-updater": "1.35.0", + "theia-blueprint-product": "1.35.0" + }, + "devDependencies": { + "@theia/cli": "1.35.0" + }, + "scripts": { + "prepare": "yarn build && yarn download:plugins", + "clean": "theia clean && rimraf node_modules", + "build": "yarn -s compile && yarn -s bundle", + "bundle": "theia build", + "compile": "tsc -b", + "rebuild": "theia rebuild:browser --cacheRoot ../..", + "start": "yarn -s rebuild && theia start --plugins=local-dir:./plugins", + "watch": "concurrently --kill-others -n tsc,bundle -c red,yellow \"tsc -b -w --preserveWatchOutput\" \"yarn -s watch:bundle\"", + "download:plugins": "theia download:plugins" + }, + "theiaPluginsDir": "plugins", + "theiaPlugins": { + "vscode.git": "https://open-vsx.org/api/vscode/git/1.52.1/file/vscode.git-1.52.1.vsix", + "vscode-builtin-extensions-pack": "https://open-vsx.org/api/eclipse-theia/builtin-extension-pack/1.50.1/file/eclipse-theia.builtin-extension-pack-1.50.1.vsix", + "redhat.java": "https://open-vsx.org/api/redhat/java/0.73.0/file/redhat.java-0.73.0.vsix", + "vscjava.vscode-java-debug": "https://open-vsx.org/api/vscjava/vscode-java-debug/0.30.0/file/vscjava.vscode-java-debug-0.30.0.vsix", + "vscjava.vscode-java-test": "https://open-vsx.org/api/vscjava/vscode-java-test/0.26.1/file/vscjava.vscode-java-test-0.26.1.vsix", + "vscjava.vscode-maven": "https://open-vsx.org/api/vscjava/vscode-maven/0.21.2/file/vscjava.vscode-maven-0.21.2.vsix", + "vscjava.vscode-java-dependency": "https://open-vsx.org/api/vscjava/vscode-java-dependency/0.16.0/file/vscjava.vscode-java-dependency-0.16.0.vsix", + "redhat.vscode-xml": "https://open-vsx.org/api/redhat/vscode-xml/0.20.0/file/redhat.vscode-xml-0.20.0.vsix" + }, + "theiaPluginsExcludeIds": [ + "ms-vscode.js-debug-companion", + "vscode.extension-editing", + "vscode.microsoft-authentication", + "vscode.html-language-features", + "vscode.git", + "vscode.git-ui", + "vscode.github", + "vscode.github-authentication", + "vscode.microsoft-authentication" + ] +} diff --git a/applications/browser/resources/preload.html b/applications/browser/resources/preload.html new file mode 100644 index 000000000..e0d34a51f --- /dev/null +++ b/applications/browser/resources/preload.html @@ -0,0 +1,91 @@ + + + + + + + + +
+
+ + + + + + + + +
+
+ + + \ No newline at end of file diff --git a/applications/browser/tsconfig.json b/applications/browser/tsconfig.json new file mode 100644 index 000000000..bcacaf5b8 --- /dev/null +++ b/applications/browser/tsconfig.json @@ -0,0 +1,12 @@ +{ + "extends": "../../configs/base.tsconfig", + "include": [], + "compilerOptions": { + "composite": true + }, + "references": [ + { + "path": "../../theia-extensions/theia-blueprint-product" + } + ] +} diff --git a/applications/browser/webpack.config.js b/applications/browser/webpack.config.js new file mode 100644 index 000000000..8bd02af31 --- /dev/null +++ b/applications/browser/webpack.config.js @@ -0,0 +1,17 @@ +/** + * This file can be edited to customize webpack configuration. + * To reset delete this file and rerun theia build again. + */ +// @ts-check +const config = require('./gen-webpack.config.js'); + +/** + * Expose bundled modules on window.theia.moduleName namespace, e.g. + * window['theia']['@theia/core/lib/common/uri']. + * Such syntax can be used by external code, for instance, for testing. +config.module.rules.push({ + test: /\.js$/, + loader: require.resolve('@theia/application-manager/lib/expose-loader') +}); */ + +module.exports = config; \ No newline at end of file diff --git a/applications/electron/package.json b/applications/electron/package.json index 142cd229e..8942d0246 100644 --- a/applications/electron/package.json +++ b/applications/electron/package.json @@ -115,10 +115,11 @@ "prepare": "yarn build && yarn download:plugins", "clean": "theia clean && rimraf node_modules", "clean:dist": "rimraf dist", - "build": "theia rebuild:electron && yarn bundle", + "build": "yarn -s bundle", "bundle": "theia build", + "rebuild": "theia rebuild:electron --cacheRoot ../..", "watch": "concurrently -n compile,bundle \"theiaext watch --preserveWatchOutput\" \"theia build --watch --mode development\"", - "start": "electron scripts/theia-electron-main.js", + "start": "yarn -s rebuild && electron scripts/theia-electron-main.js", "start:debug": "yarn start --log-level=debug", "package": "yarn clean:dist && electron-builder -c.mac.identity=null --publish never", "deploy": "yarn clean:dist && electron-builder -c.mac.identity=null --publish always", diff --git a/browser.Dockerfile b/browser.Dockerfile new file mode 100644 index 000000000..e92439830 --- /dev/null +++ b/browser.Dockerfile @@ -0,0 +1,37 @@ +FROM node:16-bullseye as build-stage +RUN apt-get update && apt-get install -y libxkbfile-dev libsecret-1-dev +WORKDIR /home/theia +COPY . . +RUN yarn --pure-lockfile && \ + yarn --production && \ + yarn autoclean --init && \ + echo *.ts >> .yarnclean && \ + echo *.ts.map >> .yarnclean && \ + echo *.spec.* >> .yarnclean && \ + yarn autoclean --force && \ + yarn cache clean + +FROM node:16-bullseye-slim as production-stage +RUN adduser --system --group theia +RUN chmod g+rw /home && \ + mkdir -p /home/project && \ + chown -R theia:theia /home/theia && \ + chown -R theia:theia /home/project; +RUN apt-get update && apt-get install -y wget apt-transport-https && \ + wget -O - https://packages.adoptium.net/artifactory/api/gpg/key/public | tee /usr/share/keyrings/adoptium.asc && \ + echo "deb [signed-by=/usr/share/keyrings/adoptium.asc] https://packages.adoptium.net/artifactory/deb $(awk -F= '/^VERSION_CODENAME/{print$2}' /etc/os-release) main" | tee /etc/apt/sources.list.d/adoptium.list && \ + apt-get update && apt-get install -y git openssh-client openssh-server bash libsecret-1-0 temurin-17-jdk maven && \ + apt-get purge -y wget && \ + apt-get clean +ENV HOME /home/theia +WORKDIR /home/theia +COPY --from=build-stage --chown=theia:theia /home/theia /home/theia +EXPOSE 3000 +ENV SHELL=/bin/bash \ + THEIA_DEFAULT_PLUGINS=local-dir:/home/theia/applications/browser/plugins +ENV USE_LOCAL_GIT true +USER theia + +WORKDIR /home/theia/applications/browser +ENTRYPOINT [ "node", "/home/theia/applications/browser/src-gen/backend/main.js" ] +CMD [ "/home/project", "--hostname=0.0.0.0" ] \ No newline at end of file diff --git a/package.json b/package.json index 8ad36947b..f85d18e20 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,7 @@ "watch": "lerna run --parallel watch", "test": "lerna run test", "electron": "yarn --cwd applications/electron", + "browser": "yarn --cwd applications/browser", "update:next": "ts-node scripts/update-theia-to-next.ts && lerna run update:next" }, "workspaces": [ diff --git a/theia-extensions/theia-blueprint-product/package.json b/theia-extensions/theia-blueprint-product/package.json index c088ff027..e77c0cdbe 100644 --- a/theia-extensions/theia-blueprint-product/package.json +++ b/theia-extensions/theia-blueprint-product/package.json @@ -17,7 +17,7 @@ }, "theiaExtensions": [ { - "frontendElectron": "lib/browser/theia-blueprint-frontend-module", + "frontend": "lib/browser/theia-blueprint-frontend-module", "electronMain": "lib/electron-main/theia-blueprint-main-module", "backend": "lib/node/theia-blueprint-backend-module" } From 1181a8b4702ee4b60996f98c4e0f9602a6531beb Mon Sep 17 00:00:00 2001 From: Johannes Faltermeier Date: Mon, 6 Mar 2023 15:34:19 +0100 Subject: [PATCH 2/4] Create Browser Application and Dockerfile #75 * Update repository structure and adapt headings in readme * Align used plugins * Add browser app start instructions * add rate limits for plugin downloads --- README.md | 21 ++++++++++++++++----- applications/browser/package.json | 11 +++++------ applications/electron/package.json | 2 +- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 5f339fd6d..5460015a4 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,8 @@ Documentation on how to package Theia as a Desktop Product may be found [here](h - Root level configures mono-repo build with lerna - `applications` groups the different app targets - - `electron` contains app to package, packaging configuration, and E2E tests for the electron target. + - `browser` contains a browser based version of Eclipse Theia Blueprint that may be packaged as a Docker image + - `electron` contains the electron app to package, packaging configuration, and E2E tests for the electron target. - `theia-extensions` groups the various custom theia extensions for Blueprint - `theia-blueprint-product` contains a Theia extension contributing the product branding (about dialogue and welcome page). - `theia-blueprint-updater` contains a Theia extension contributing the update mechanism and corresponding UI elements (based on the electron updater). @@ -61,7 +62,7 @@ Documentation on how to package Theia as a Desktop Product may be found [here](h yarn ``` -### Package the Application +### Package the Electron Application ```sh yarn electron package @@ -69,7 +70,7 @@ yarn electron package The packaged application is located in `applications/electron/dist`. -### Create a Preview Application (without packaging it) +### Create a Preview Electron Application (without packaging it) ```sh yarn electron package:preview @@ -77,7 +78,7 @@ yarn electron package:preview The packaged application is located in `applications/electron/dist`. -### Running E2E Tests +### Running E2E Tests on Electron The E2E tests basic UI tests of the actual application. This is done based on the preview of the packaged application. @@ -87,6 +88,16 @@ yarn electron package:preview yarn electron test ``` +### Running Browser app + +The browser app may be started with + +```sh +yarn browser start +``` + +and connect to + ### Troubleshooting - [_"Don't expect that you can build app for all platforms on one platform."_](https://www.electron.build/multi-platform-build) @@ -98,7 +109,7 @@ Eclipse Theia Blueprint only packages existing functionality into a product and ### Docker Build -You can create a Docker Image for Blueprint with the following build command: +You can create a Docker Image for Blueprint based on the browser app with the following build command: ```sh docker build -t theia-blueprint -f browser.Dockerfile . diff --git a/applications/browser/package.json b/applications/browser/package.json index 0dcb2a3c7..46f61f1c3 100644 --- a/applications/browser/package.json +++ b/applications/browser/package.json @@ -97,24 +97,23 @@ "rebuild": "theia rebuild:browser --cacheRoot ../..", "start": "yarn -s rebuild && theia start --plugins=local-dir:./plugins", "watch": "concurrently --kill-others -n tsc,bundle -c red,yellow \"tsc -b -w --preserveWatchOutput\" \"yarn -s watch:bundle\"", - "download:plugins": "theia download:plugins" + "download:plugins": "theia download:plugins --rate-limit=1" }, "theiaPluginsDir": "plugins", "theiaPlugins": { - "vscode.git": "https://open-vsx.org/api/vscode/git/1.52.1/file/vscode.git-1.52.1.vsix", + "vscode.markdown-language-features": "https://open-vsx.org/api/vscode/markdown-language-features/1.39.2/file/vscode.markdown-language-features-1.39.2.vsix", "vscode-builtin-extensions-pack": "https://open-vsx.org/api/eclipse-theia/builtin-extension-pack/1.50.1/file/eclipse-theia.builtin-extension-pack-1.50.1.vsix", + "vscode.typescript": "https://open-vsx.org/api/vscode/typescript/1.62.3/file/vscode.typescript-1.62.3.vsix", + "vscode.typescript-language-features": "https://open-vsx.org/api/vscode/typescript-language-features/1.62.3/file/vscode.typescript-language-features-1.62.3.vsix", "redhat.java": "https://open-vsx.org/api/redhat/java/0.73.0/file/redhat.java-0.73.0.vsix", "vscjava.vscode-java-debug": "https://open-vsx.org/api/vscjava/vscode-java-debug/0.30.0/file/vscjava.vscode-java-debug-0.30.0.vsix", "vscjava.vscode-java-test": "https://open-vsx.org/api/vscjava/vscode-java-test/0.26.1/file/vscjava.vscode-java-test-0.26.1.vsix", "vscjava.vscode-maven": "https://open-vsx.org/api/vscjava/vscode-maven/0.21.2/file/vscjava.vscode-maven-0.21.2.vsix", - "vscjava.vscode-java-dependency": "https://open-vsx.org/api/vscjava/vscode-java-dependency/0.16.0/file/vscjava.vscode-java-dependency-0.16.0.vsix", - "redhat.vscode-xml": "https://open-vsx.org/api/redhat/vscode-xml/0.20.0/file/redhat.vscode-xml-0.20.0.vsix" + "vscjava.vscode-java-dependency": "https://open-vsx.org/api/vscjava/vscode-java-dependency/0.16.0/file/vscjava.vscode-java-dependency-0.16.0.vsix" }, "theiaPluginsExcludeIds": [ "ms-vscode.js-debug-companion", "vscode.extension-editing", - "vscode.microsoft-authentication", - "vscode.html-language-features", "vscode.git", "vscode.git-ui", "vscode.github", diff --git a/applications/electron/package.json b/applications/electron/package.json index 8942d0246..5983874ce 100644 --- a/applications/electron/package.json +++ b/applications/electron/package.json @@ -126,7 +126,7 @@ "package:preview": "yarn clean:dist && electron-builder -c.mac.identity=null --dir", "update:checksum": "ts-node scripts/update-checksum.ts", "update:next": "ts-node ../../scripts/update-theia-to-next.ts", - "download:plugins": "theia download:plugins", + "download:plugins": "theia download:plugins --rate-limit=1", "test": "mocha --timeout 60000 \"./test/*.spec.js\"" }, "theiaPluginsDir": "plugins", From ef689826369e61ae1489ccbfb9c9d96a9a1ad18c Mon Sep 17 00:00:00 2001 From: Johannes Faltermeier Date: Tue, 7 Mar 2023 10:59:29 +0100 Subject: [PATCH 3/4] Create Browser Application and Dockerfile #75 * Remove updater from browser app --- applications/browser/package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/applications/browser/package.json b/applications/browser/package.json index 46f61f1c3..a2714ae58 100644 --- a/applications/browser/package.json +++ b/applications/browser/package.json @@ -82,7 +82,6 @@ "@theia/vsx-registry": "1.35.0", "@theia/workspace": "1.35.0", "fs-extra": "^9.0.1", - "theia-blueprint-updater": "1.35.0", "theia-blueprint-product": "1.35.0" }, "devDependencies": { From c8b5e3b961233304b35a59f60255393ecbc63756 Mon Sep 17 00:00:00 2001 From: Johannes Faltermeier Date: Tue, 7 Mar 2023 12:32:05 +0100 Subject: [PATCH 4/4] Create Browser Application and Dockerfile #75 * Try to fix javascript out of heap errors in windows workflow --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f85d18e20..cbed596aa 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "yargs": "17.2.1" }, "scripts": { - "prepare": "lerna run prepare", + "prepare": "lerna run prepare --concurrency 1", "lint": "lerna run lint", "lint:fix": "lerna run lint:fix", "clean": "lerna run clean && rimraf node_modules",