-
Notifications
You must be signed in to change notification settings - Fork 111
Remote binary #267
Remote binary #267
Changes from 6 commits
45a0c23
99ae354
5e1be64
0c8dd2d
09a8c15
59f3141
1a913c2
9019ddb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
theia-plugin-ext | ||
docker-build | ||
.browser_modules | ||
*.log | ||
*-app/* | ||
!*-app/package.json | ||
.idea | ||
.Dockerfile |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# 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 | ||
# | ||
# Contributors: | ||
# Red Hat, Inc. - initial API and implementation | ||
|
||
FROM ${BUILD_ORGANIZATION}/${BUILD_PREFIX}-theia-dev:${BUILD_TAG} as builder | ||
|
||
|
||
# define in env variable GITHUB_TOKEN only if it is defined | ||
# else check if github rate limit is enough, else will abort requiring to set GITHUB_TOKEN value | ||
ARG GITHUB_TOKEN | ||
|
||
# Check github limit | ||
RUN if [ ! -z "${GITHUB_TOKEN-}" ]; then \ | ||
export GITHUB_TOKEN=$GITHUB_TOKEN; \ | ||
echo "Setting GITHUB_TOKEN value as provided"; \ | ||
else \ | ||
export GITHUB_LIMIT=$(curl -s 'https://api.github.com/rate_limit' | jq '.rate .remaining'); \ | ||
echo "Current API rate limit https://api.github.com is ${GITHUB_LIMIT}"; \ | ||
if [ "${GITHUB_LIMIT}" -lt 10 ]; then \ | ||
printf "\033[0;31m\n\n\nRate limit on https://api.github.com is reached so in order to build this image, "; \ | ||
printf "the build argument GITHUB_TOKEN needs to be provided so build will not fail.\n\n\n\033[0m"; \ | ||
exit 1; \ | ||
else \ | ||
echo "GITHUB_TOKEN variable is not set but https://api.github.com rate limit has enough slots"; \ | ||
fi \ | ||
fi | ||
|
||
#invalidate cashe | ||
ADD https://${GITHUB_TOKEN}:x-oauth-basic@api.github.com/repos/theia-ide/theia/git/refs/head /tmp/branch_info.json | ||
ADD https://${GITHUB_TOKEN}:x-oauth-basic@api.github.com/repos/eclipse/che-theia/git/refs/head /tmp/branch_info.json | ||
|
||
# Grab dependencies | ||
COPY /docker-build/theia-plugin-remote/package.json /home/workspace/packages/theia-remote/ | ||
RUN cd /home/workspace/packages/theia-remote/ && yarn install --ignore-scripts | ||
|
||
# Compile | ||
COPY /docker-build/configs /home/workspace/configs | ||
COPY /docker-build/theia-plugin-remote/*.json /home/workspace/packages/theia-remote/ | ||
COPY /docker-build/theia-plugin-remote/src /home/workspace/packages/theia-remote/src | ||
COPY /docker-build/theia-plugin-ext /home/workspace/packages/theia-plugin-ext | ||
COPY /docker-build/theia-plugin /home/workspace/packages/theia-plugin | ||
COPY /docker-build/theia-plugin-remote/tsconfig.json /home/workspace/packages/theia-plugin/tsconfig.json | ||
|
||
COPY /etc/package.json /home/workspace | ||
RUN cd /home/workspace/ && yarn install | ||
|
||
RUN yarn global add nexe@3.2.0 && nexe -v | ||
WORKDIR /home/workspace | ||
|
||
# Fix theia-plugin-ext dependency | ||
RUN rm -rf /home/workspace/node_modules/@eclipse-che/theia-plugin-ext /home/workspace/node_modules/@eclipse-che/theia-remote | ||
RUN cp -rf /home/workspace/packages/theia-plugin-ext /home/workspace/node_modules/@eclipse-che/theia-plugin-ext | ||
|
||
RUN nexe packages/theia-remote/lib/node/plugin-remote.js -t alpine-x64-10.14.2 -o plugin-remote | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is that the binary is running on pure alpine image after that ? AFAIK there was still some mandatory libraries required to run on a plain alpine image There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm... I tested two remote plugins: typescript and my custom with this binary on the pure alpine - they were working... 99ae354#diff-f7eaf7e082319e42b2dfd26a86ca0736R80 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. alpine image is just |
||
|
||
|
||
FROM registry.access.redhat.com/ubi8/ubi-minimal | ||
|
||
COPY --from=builder /home/workspace/plugin-remote /plugin-remote | ||
|
||
RUN mkdir /projects /home/theia \ | ||
# Store passwd/group as template files | ||
&& cat /etc/passwd | sed s#root:x.*#root:x:\${USER_ID}:\${GROUP_ID}::\${HOME}:/bin/sh#g > ${HOME}/passwd.template \ | ||
&& cat /etc/group | sed s#root:x:0:#root:x:0:0,\${USER_ID}:#g > ${HOME}/group.template \ | ||
# Change permissions to let any arbitrary user | ||
&& for f in "${HOME}" "/etc/passwd" "/etc/group" "/projects"; do \ | ||
echo "Changing permissions on ${f}" && chgrp -R 0 ${f} && \ | ||
chmod -R g+rwX ${f}; \ | ||
done | ||
|
||
ADD etc/entrypoint.sh /entrypoint.sh | ||
ENTRYPOINT ["/entrypoint.sh"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/bin/bash | ||
# | ||
# 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 | ||
|
||
base_dir=$(cd "$(dirname "$0")"; pwd) | ||
. "${base_dir}"/../build.include | ||
|
||
DIR=$(cd "$(dirname "$0")"; pwd) | ||
LOCAL_ASSEMBLY_DIR="${DIR}"/docker-build | ||
|
||
if [ -d "${LOCAL_ASSEMBLY_DIR}" ]; then | ||
rm -rf "${LOCAL_ASSEMBLY_DIR}" | ||
fi | ||
|
||
#in mac os 'cp' cannot create destination dir, so create it first | ||
mkdir ${LOCAL_ASSEMBLY_DIR} | ||
|
||
echo "Copying ${base_dir}/../../extensions/eclipse-che-theia-plugin --> ${LOCAL_ASSEMBLY_DIR}/theia-plugin" | ||
mkdir ${LOCAL_ASSEMBLY_DIR}/theia-plugin | ||
cp -r "${base_dir}/../../extensions/eclipse-che-theia-plugin/src/." "${LOCAL_ASSEMBLY_DIR}/theia-plugin/src/" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe it is worth to create another constant which holds |
||
cp -r "${base_dir}/../../extensions/eclipse-che-theia-plugin/package.json" "${LOCAL_ASSEMBLY_DIR}/theia-plugin" | ||
|
||
echo "Copying ${base_dir}/../../extensions/eclipse-che-theia-plugin-ext --> ${LOCAL_ASSEMBLY_DIR}/theia-plugin-ext" | ||
mkdir ${LOCAL_ASSEMBLY_DIR}/theia-plugin-ext | ||
cp -r "${base_dir}/../../extensions/eclipse-che-theia-plugin-ext/src/." "${LOCAL_ASSEMBLY_DIR}/theia-plugin-ext/src/" | ||
cp -r "${base_dir}/../../extensions/eclipse-che-theia-plugin-ext/package.json" "${LOCAL_ASSEMBLY_DIR}/theia-plugin-ext" | ||
cp -r "${base_dir}/../../extensions/eclipse-che-theia-plugin-ext/tsconfig.json" "${LOCAL_ASSEMBLY_DIR}/theia-plugin-ext" | ||
cp -r "${base_dir}/../../extensions/eclipse-che-theia-plugin-ext/webpack.config.js" "${LOCAL_ASSEMBLY_DIR}/theia-plugin-ext" | ||
|
||
echo "Copying ${base_dir}/../../configs --> ${LOCAL_ASSEMBLY_DIR}/configs" | ||
cp -r "${base_dir}/../../configs/." "${LOCAL_ASSEMBLY_DIR}/configs" | ||
|
||
echo "Copying ${base_dir}/../../extensions/eclipse-che-theia-plugin-remote --> ${LOCAL_ASSEMBLY_DIR}/theia-plugin-remote" | ||
mkdir ${LOCAL_ASSEMBLY_DIR}/theia-plugin-remote | ||
cp -r "${base_dir}/../../extensions/eclipse-che-theia-plugin-remote/src/." "${LOCAL_ASSEMBLY_DIR}/theia-plugin-remote/src/" | ||
cp -r "${base_dir}/../../extensions/eclipse-che-theia-plugin-remote/package.json" "${LOCAL_ASSEMBLY_DIR}/theia-plugin-remote" | ||
cp -r "${base_dir}/../../extensions/eclipse-che-theia-plugin-remote/tsconfig.json" "${LOCAL_ASSEMBLY_DIR}/theia-plugin-remote" | ||
|
||
|
||
init --name:theia-endpoint-runtime-binary "$@" | ||
build |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#!/bin/sh | ||
# | ||
# Copyright (c) 2018-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 | ||
# | ||
# Contributors: | ||
# Red Hat, Inc. - initial API and implementation | ||
# | ||
|
||
export USER_ID=$(id -u) | ||
export GROUP_ID=$(id -g) | ||
|
||
if ! grep -Fq "${USER_ID}" /etc/passwd; then | ||
# current user is an arbitrary | ||
# user (its uid is not in the | ||
# container /etc/passwd). Let's fix that | ||
cat ${HOME}/passwd.template | \ | ||
sed "s/\${USER_ID}/${USER_ID}/g" | \ | ||
sed "s/\${GROUP_ID}/${GROUP_ID}/g" | \ | ||
sed "s/\${HOME}/\/home\/theia/g" > /etc/passwd | ||
|
||
cat ${HOME}/group.template | \ | ||
sed "s/\${USER_ID}/${USER_ID}/g" | \ | ||
sed "s/\${GROUP_ID}/${GROUP_ID}/g" | \ | ||
sed "s/\${HOME}/\/home\/theia/g" > /etc/group | ||
fi | ||
|
||
# Grant access to projects volume in case of non root user with sudo rights | ||
if [ "$(id -u)" -ne 0 ] && command -v sudo >/dev/null 2>&1 && sudo -n true > /dev/null 2>&1; then | ||
sudo chown ${USER_ID}:${GROUP_ID} /projects | ||
fi | ||
|
||
# SITTERM / SIGINT | ||
responsible_shutdown() { | ||
echo "" | ||
echo "Received SIGTERM" | ||
kill -INT ${PID} | ||
wait ${PID} | ||
exit; | ||
} | ||
|
||
set -e | ||
|
||
# setup handlers | ||
# on callback, kill the last background process, which is `tail -f /dev/null` and execute the specified handler | ||
trap 'responsible_shutdown' HUP TERM INT | ||
|
||
cd ${HOME} | ||
|
||
# run theia endpoint | ||
/plugin-remote & | ||
|
||
PID=$! | ||
|
||
# See: http://veithen.github.io/2014/11/16/sigterm-propagation.html | ||
wait ${PID} | ||
wait ${PID} | ||
EXIT_STATUS=$? | ||
|
||
# wait forever | ||
while true | ||
do | ||
tail -f /dev/null & wait ${!} | ||
done |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"private": true, | ||
"workspaces": [ | ||
"packages/*" | ||
], | ||
"devDependencies": { | ||
"tslint": "5.10.0", | ||
"rimraf": "2.6.2", | ||
"typescript": "3.1.3", | ||
"typescript-formatter": "7.2.2" | ||
}, | ||
"scripts": { | ||
"prepare": "yarn run clean && yarn run tslint && yarn run build", | ||
"tslint-fix": "tslint --fix --project packages/theia-remote", | ||
"tslint": "tslint --project packages/theia-remote", | ||
"clean": "rimraf packages/**/lib", | ||
"format-code": "tsfmt -r --baseDir packages/theia-remote && tsfmt -r --baseDir packages/theia-plugin-ext", | ||
"compile": "tsc -b packages/**", | ||
"build": "yarn run format-code && yarn run compile && yarn run tslint-fix" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,4 +67,3 @@ RUN mkdir /projects \ | |
done | ||
ADD etc/entrypoint.sh /entrypoint.sh | ||
ENTRYPOINT ["/entrypoint.sh"] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,19 +10,19 @@ | |
|
||
import { ExtPluginApiProvider, ExtPluginApi } from '@theia/plugin-ext/lib/common/plugin-ext-api-contribution'; | ||
import { injectable } from 'inversify'; | ||
import * as path from 'path'; | ||
|
||
@injectable() | ||
export class ChePluginApiProvider implements ExtPluginApiProvider { | ||
|
||
provideApi(): ExtPluginApi { | ||
console.log('provide che plugin api!!!'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pls remove the trace |
||
return { | ||
frontendExtApi: { | ||
initPath: '/che/api/che-api-worker-provider.js', | ||
initFunction: 'initializeApi', | ||
initVariable: 'che_api_provider' | ||
}, | ||
backendInitPath: path.join(__dirname, '../plugin/node/che-api-node-provider.js') | ||
backendInitPath: '@eclipse-che/theia-plugin-ext/lib/plugin/node/che-api-node-provider.js' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in theia, we don't have path.join as well anymore ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see no more api providers in the theia repo, only in the README.md: https://github.com/theia-ide/theia/blob/master/packages/plugin-ext/doc/how-to-add-new-plugin-namespace.md#declare-extpluginapiprovider-implementation There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
}; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,13 @@ const localModule = ConnectionContainerModule.create(({ bind }) => { | |
}); | ||
|
||
export default new ContainerModule(bind => { | ||
try { | ||
// Force nexe to include theia-plugin-ext iside binary | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. typo |
||
require('@eclipse-che/theia-plugin-ext/lib/node/che-plugin-api-provider.js'); | ||
} catch (err) { | ||
console.log('Unable to set up che theia plugin api: ', err); | ||
} | ||
|
||
bind(HostedPluginMapping).toSelf().inSingletonScope(); | ||
bind(MetadataProcessor).to(RemoteMetadataProcessor).inSingletonScope(); | ||
bind(ConnectionContainerModule).toConstantValue(localModule); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo on cache