This repository has been archived by the owner on Apr 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 111
Remote binary #267
Closed
Closed
Remote binary #267
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
45a0c23
Make binare for remote-plugin-endpoint
AndrienkoAleksandr 99ae354
Improve code. Test a lot images.
AndrienkoAleksandr 5e1be64
Merge branch 'master' of github.com:eclipse/che-theia into remoteBinary
AndrienkoAleksandr 0c8dd2d
Created separated docker file for remote-plugin-binary.
AndrienkoAleksandr 09a8c15
Fix image name in the build script. Code clean up.
AndrienkoAleksandr 59f3141
Clean up.
AndrienkoAleksandr 1a913c2
Merge branch 'master' of github.com:eclipse/che-theia into remoteBinary
AndrienkoAleksandr 9019ddb
Address changes.
AndrienkoAleksandr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 cache | ||
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 | ||
|
||
|
||
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/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} | ||
|
||
app_root=${base_dir}/../.. | ||
|
||
echo "Copying ${app_root}/extensions/eclipse-che-theia-plugin --> ${LOCAL_ASSEMBLY_DIR}/theia-plugin" | ||
mkdir ${LOCAL_ASSEMBLY_DIR}/theia-plugin | ||
cp -r "${app_root}/extensions/eclipse-che-theia-plugin/src/." "${LOCAL_ASSEMBLY_DIR}/theia-plugin/src/" | ||
cp -r "${app_root}/extensions/eclipse-che-theia-plugin/package.json" "${LOCAL_ASSEMBLY_DIR}/theia-plugin" | ||
|
||
echo "Copying ${app_root}/extensions/eclipse-che-theia-plugin-ext --> ${LOCAL_ASSEMBLY_DIR}/theia-plugin-ext" | ||
mkdir ${LOCAL_ASSEMBLY_DIR}/theia-plugin-ext | ||
cp -r "${app_root}/extensions/eclipse-che-theia-plugin-ext/src/." "${LOCAL_ASSEMBLY_DIR}/theia-plugin-ext/src/" | ||
cp -r "${app_root}/extensions/eclipse-che-theia-plugin-ext/package.json" "${LOCAL_ASSEMBLY_DIR}/theia-plugin-ext" | ||
cp -r "${app_root}/extensions/eclipse-che-theia-plugin-ext/tsconfig.json" "${LOCAL_ASSEMBLY_DIR}/theia-plugin-ext" | ||
cp -r "${app_root}/extensions/eclipse-che-theia-plugin-ext/webpack.config.js" "${LOCAL_ASSEMBLY_DIR}/theia-plugin-ext" | ||
|
||
echo "Copying ${app_root}/configs --> ${LOCAL_ASSEMBLY_DIR}/configs" | ||
cp -r "${app_root}/configs/." "${LOCAL_ASSEMBLY_DIR}/configs" | ||
|
||
echo "Copying ${app_root}/extensions/eclipse-che-theia-plugin-remote --> ${LOCAL_ASSEMBLY_DIR}/theia-plugin-remote" | ||
mkdir ${LOCAL_ASSEMBLY_DIR}/theia-plugin-remote | ||
cp -r "${app_root}/extensions/eclipse-che-theia-plugin-remote/src/." "${LOCAL_ASSEMBLY_DIR}/theia-plugin-remote/src/" | ||
cp -r "${app_root}/extensions/eclipse-che-theia-plugin-remote/package.json" "${LOCAL_ASSEMBLY_DIR}/theia-plugin-remote" | ||
cp -r "${app_root}/extensions/eclipse-che-theia-plugin-remote/tsconfig.json" "${LOCAL_ASSEMBLY_DIR}/theia-plugin-remote" | ||
|
||
|
||
init --name:theia-endpoint-runtime-binary "$@" | ||
build |
68 changes: 68 additions & 0 deletions
68
dockerfiles/theia-endpoint-runtime-binary/etc/entrypoint.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
21 changes: 21 additions & 0 deletions
21
dockerfiles/theia-endpoint-runtime-binary/etc/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,6 @@ | |
|
||
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 { | ||
|
@@ -22,7 +21,7 @@ export class ChePluginApiProvider implements ExtPluginApiProvider { | |
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. |
||
}; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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 comment
The 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
Could you elaborate more about mandatory libraries ?
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.
alpine image is just
alpine:latest
or was there some other packages installed?my attempt was with pkg and not nexe so it might different, it was requiring
libstdc++
packagevercel/pkg#555