Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin' into vscode-diff
Browse files Browse the repository at this point in the history
  • Loading branch information
vzhukovs committed Nov 27, 2019
2 parents b34b153 + 2170465 commit 21a46c2
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ RUN apk add --update --no-cache \
# compile some javascript native stuff (node-gyp)
make gcc g++ python \
# clone repositories (and also using ssh repositories)
git openssh openssh-keygen \
git openssh openssh-keygen man git-doc \
# Handle git diff properly
less \
# bash shell
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
USER root
RUN yum install -y curl make cmake gcc gcc-c++ python2 git openssh less bash tar gzip \
RUN yum install -y curl make cmake gcc gcc-c++ python2 git git-core-doc openssh less bash tar gzip \
&& yum -y clean all && rm -rf /var/cache/yum
1 change: 1 addition & 0 deletions dockerfiles/theia/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -163,5 +163,6 @@ COPY --from=builder /home/theia-dev/theia-source-code/production/plugins /defaul
COPY --chown=theia:root --from=builder /home/theia-dev/theia-source-code/production /home/theia
USER theia
WORKDIR /projects
COPY src/get-webview-route.js ${HOME}/get-webview-route.js
COPY src/entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
3 changes: 2 additions & 1 deletion dockerfiles/theia/src/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ if [ "${NOCDN}" == "true" ]; then
fi
shopt -u nocasematch

# run che
# run Che Theia
export THEIA_WEBVIEW_EXTERNAL_ENDPOINT=$(node get-webview-route.js)
node src-gen/backend/main.js /projects --hostname=0.0.0.0 --port=${THEIA_PORT} &

PID=$!
Expand Down
73 changes: 73 additions & 0 deletions dockerfiles/theia/src/get-webview-route.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*********************************************************************
* Copyright (c) 2019 Red Hat, Inc.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/

const fs = require('fs');
const workspaceClient = require('@eclipse-che/workspace-client');

// Assume that self-signed certificate is located by the following path
const SS_CRT_PATH = '/tmp/che/secret/ca.crt';

// Configure workspace API client
const restAPIConfig = {
baseUrl: process.env.CHE_API
};

const token = process.env.CHE_MACHINE_TOKEN;
if (token) {
restAPIConfig.headers = {};
restAPIConfig.headers['Authorization'] = 'Bearer ' + token;
}

if (fs.existsSync(SS_CRT_PATH)) {
restAPIConfig.ssCrtPath = SS_CRT_PATH;
}

// Create rest API workspace client
const restApiClient = workspaceClient.default.getRestApi(restAPIConfig);

// Search for IDE route
function getIdeRoute() {
return new Promise((resolve, reject) => {
restApiClient.getById(process.env.CHE_WORKSPACE_ID).then(workspace => {
const containers = workspace.runtime.machines;
Object.keys(containers).forEach(containerName => {
const container = containers[containerName];
const servers = container['servers'];
if (servers) {
const ideServerName = Object.keys(servers).find(serverName => servers[serverName].attributes && servers[serverName].attributes['type'] === 'ide');
if (ideServerName) {
resolve(servers[ideServerName].url);
}
}
});
reject('Server with type "ide" not found.');
}).catch(error => {
reject(error);
});
});
}

getIdeRoute().then(ideRoute => {
if (!ideRoute) {
throw new Error('Failed to get ide route.');
}

// Remove trailing slash if any
if (ideRoute.endsWith('/')) {
ideRoute = ideRoute.substring(0, ideRoute.length - 1);
}
// Remove protocol
const webviewDomain = ideRoute.replace(/^https?:\/\//, '');
// Return result to shell by writing into stdout
process.stdout.write(webviewDomain);
}).catch(error => {
console.error('Unable to get IDE route. Webviews might not work. Cause:', error);
// Just exit this script without returning a value to the shell.
});
2 changes: 0 additions & 2 deletions extensions/eclipse-che-theia-plugin-remote/devfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ components:
- type: cheEditor
id: eclipse/che-theia/next
alias: theia-editor
- type: chePlugin
id: eclipse/che-machine-exec-plugin/next
- type: chePlugin
id: che-incubator/typescript/latest
memoryLimit: 2Gi
Expand Down
3 changes: 2 additions & 1 deletion generator/src/templates/assembly-package.mst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"frontend": {
"config": {
"preferences": {
"editor.autoSave": "on"
"editor.autoSave": "on",
"git.defaultCloneDirectory": "/projects"
}
}
}
Expand Down

0 comments on commit 21a46c2

Please sign in to comment.