Skip to content
This repository has been archived by the owner on Oct 18, 2024. It is now read-only.

Commit

Permalink
Merge pull request #41 from PizzaFactory/prp-update-to-the-upstream
Browse files Browse the repository at this point in the history
Update to the upstream
  • Loading branch information
monaka authored Aug 16, 2019
2 parents d48930e + 6edde93 commit 40f095b
Show file tree
Hide file tree
Showing 41 changed files with 1,490 additions and 1,257 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<div id="badges" align="center">

[![Build Status](https://ci.codenvycorp.com/buildStatus/icon?job=che-theia-master-ci)](https://ci.codenvycorp.com/job/che-theia-master-ci)
[![Build Status](https://ci.codenvycorp.com/buildStatus/icon?job=che-theia-next)](https://ci.codenvycorp.com/job/che-theia-next)
[![mattermost](https://img.shields.io/badge/chat-on%20mattermost-blue.svg)](https://mattermost.eclipse.org/eclipse/channels/eclipse-che-ide2-team)
[![Open questions](https://img.shields.io/badge/Open-questions-blue.svg?style=flat-curved)](https://github.com/eclipse/che/issues?utf8=%E2%9C%93&q=label%3Aarea%2Ftheia+label%3Akind%2Fquestion+)
[![Open bugs](https://img.shields.io/badge/Open-bugs-red.svg?style=flat-curved)](https://github.com/eclipse/che/issues?utf8=%E2%9C%93&q=label%3Aarea%2Ftheia+label%3Akind%2Fbug+)
Expand Down Expand Up @@ -87,7 +87,7 @@ Contributing to che-theia section is cover in [CONTRIBUTING.md](https://github.c
Building images is required only if you make some changes on `Dockerfile`s inside `dockerfiles` folder.
If it is about testing che-theia extensions or plugins, please refere to [CONTRIBUTING.md](https://github.com/eclipse/che-theia/blob/master/CONTRIBUTING.md).

To build che-theia docker images, please follow [dockerfiles/theia/README.md](https://github.com/eclipse/che-theia/blob/README-docker-image/dockerfiles/theia/README.md) instructions.
To build che-theia docker images, please follow [dockerfiles/theia/README.md](https://github.com/eclipse/che-theia/blob/master/dockerfiles/theia/README.md) instructions.


# License
Expand Down
3 changes: 3 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ jobs:
vmImage: 'Ubuntu-16.04'

steps:
- script: yarn
displayName: Run yarn.

- script: |
cd dockerfiles/theia-dev
./build.sh --build-arg:GITHUB_TOKEN=$(github_token) --organization:$(organization) --tag:$(tag) --prefix:$(prefix)
Expand Down
47 changes: 0 additions & 47 deletions build_and_push_docker_images.sh

This file was deleted.

3 changes: 2 additions & 1 deletion devfiles/che-theia-all.devfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ components:
attributes:
protocol: http
public: 'true'
memoryLimit: "2Gi"
memoryLimit: "3Gi"

- id: redhat/vscode-yaml/latest
type: chePlugin
Expand All @@ -47,6 +47,7 @@ components:
- type: cheEditor
alias: theia-editor
id: eclipse/che-theia/7.0.0-rc-3.0
memoryLimit: "1Gi"
commands:

- name: init ... DEV che-theia
Expand Down
2 changes: 2 additions & 0 deletions dockerfiles/theia-dev/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
generator/
.Dockerfile
4 changes: 2 additions & 2 deletions dockerfiles/theia-dev/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ ENV HOME=/home/theia-dev \
THEIA_ELECTRON_SKIP_REPLACE_FFMPEG=true

# Define package of the theia generator to use
ARG THEIA_GENERATOR_PACKAGE=@eclipse-che/theia-generator@0.0.1-1562767926
COPY generator/eclipse-che-theia-generator.tgz ${HOME}/eclipse-che-theia-generator.tgz

WORKDIR ${HOME}

Expand All @@ -50,7 +50,7 @@ EXPOSE 3000 3030
RUN npm config set prefix "${HOME}/.npm-global" && \
echo "--global-folder \"${HOME}/.yarn-global\"" > ${HOME}/.yarnrc && \
# add eclipse che theia generator
yarn global add yo @theia/generator-plugin@0.0.1-1540209403 ${THEIA_GENERATOR_PACKAGE} && \
yarn global add yo @theia/generator-plugin@0.0.1-1540209403 file:${HOME}/eclipse-che-theia-generator.tgz && \
# Generate .passwd.template \
cat /etc/passwd | \
sed s#root:x.*#theia-dev:x:\${USER_ID}:\${GROUP_ID}::${HOME}:/bin/bash#g \
Expand Down
20 changes: 20 additions & 0 deletions dockerfiles/theia-dev/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,26 @@
base_dir=$(cd "$(dirname "$0")"; pwd)
. "${base_dir}"/../build.include


DIR=$(cd "$(dirname "$0")"; pwd)
LOCAL_ASSEMBLY_DIR="${DIR}"/generator

if [ -d "${LOCAL_ASSEMBLY_DIR}" ]; then
rm -r "${LOCAL_ASSEMBLY_DIR}"
fi

#in mac os 'cp' cannot create destination dir, so create it first
mkdir ${LOCAL_ASSEMBLY_DIR}

FILE="${base_dir}"/../../generator/eclipse-che-theia-generator.tgz
if [ -f "$FILE" ]; then
cp "${FILE}" "${LOCAL_ASSEMBLY_DIR}"
else
echo "$FILE does not exist, trying to generate..."
(cd "${base_dir}"/../../generator/ && yarn prepare && yarn pack --filename eclipse-che-theia-generator.tgz)
cp "${FILE}" "${LOCAL_ASSEMBLY_DIR}"
fi

init --name:theia-dev "$@"
build
if ! skip_tests; then
Expand Down
12 changes: 4 additions & 8 deletions dockerfiles/theia/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,11 @@ ARG CDN_PREFIX=""
ARG MONACO_CDN_PREFIX=""
WORKDIR ${HOME}/theia-source-code

COPY che-theia/che-theia-init-sources.yml ${HOME}/che-theia-init-sources.yml
#add che-theia repository content
ADD che-theia/che-theia.tar.gz ${HOME}/theia-source-code/che-theia

#invalidate cache for che-theia extensions
ADD https://${GITHUB_TOKEN}:x-oauth-basic@api.github.com/repos/eclipse/che-theia/git/${GIT_REF} /tmp/this_branch_info.json

RUN che:theia init -c ${HOME}/che-theia-init-sources.yml
# run che:theia init command and alias che-theia repository to use local sources insted of cloning
RUN che:theia init -c ${HOME}/theia-source-code/che-theia/che-theia-init-sources.yml --alias https://github.com/eclipse/che-theia=${HOME}/theia-source-code/che-theia

RUN che:theia cdn --theia="${CDN_PREFIX}" --monaco="${MONACO_CDN_PREFIX}"

Expand All @@ -79,9 +78,6 @@ RUN yarn
# Run into production mode
RUN che:theia production

# FIX ME, temporary fix to restore build
RUN cd che/che-theia && git reset --hard

# Compile plugins
RUN cd plugins && ./foreach_yarn

Expand Down
115 changes: 101 additions & 14 deletions dockerfiles/theia/README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,120 @@
# How to Build Theia Image

## Build image manually using build scripts
To build Theia image manually You could use build.sh scripts.
Dockerfile uses multi-stage build feature, so first of all You need build builder image -
theia-dev:

Example:
To build all the images you can easily run [build.sh](../../build.sh) script located in the repository root. It will build container with Theia editor, dev container with tools to develop on TypeScript and containers containing remote plugins.

```shell
$ ../theia-dev/build.sh
```bash
./build.sh
```

CI for checking any pull request in this repository runs this script with `--pr` directive
```bash
`build.sh --pr`.
```

**Note**: `--pr` will build only [limited set](../../docker_image_build.include) of docker images.

## How to build own Che Theia image with Docker

[Che-Theia](Dockerfile) image is based on [Theia-Dev](../theia-dev/Dockerfile) image, which contains a set of tools for TypeScript development.
Also theia-dev image includes `@theia/generator-plugin` which can be easily used in both Theia-Dev and Che-Theia containers.

Build script always use current Che-Theia sources. To test your changes you don't need to push your changes somewhere. Just go to `dockerfiles/theia` directory and run:

```bash
./build.sh --build-args:GITHUB_TOKEN=${GITHUB_TOKEN},THEIA_VERSION=master --tag:next --branch:master --git-ref:refs\\/heads\\/master
```

After that, You can build Theia image.
Where [`${GITHUB_TOKEN}`](#github-token) is your GitHub API token, it's used for fetching some vscode libraries that placed on GitHub releases. Without that token build will fail.

Example:
This script will build new docker image `eclipse/che-theia:next`. The image will contain Che-Theia based on Theia from master branch.

## Build arguments

General command to build Che-Theia with all possible argiments:

```bash
$ ./build.sh --build-args:GITHUB_TOKEN=$GITHUB_TOKEN,THEIA_VERSION=0.3.18 --git-ref:refs\\/heads\\/master
./build.sh --build-args:GITHUB_TOKEN=${GITHUB_TOKEN},THEIA_VERSION=${THEIA_VERSION} --tag:${IMAGE_TAG} --branch:${THEIA_BRANCH} --git-ref:${THEIA_GIT_REFS} --skip-tests
```

### GitHub Token

**`${GITHUB_TOKEN}`**

This is your GitHub token. Some Theia dependencies placed on GitHub repository and fetched from the GitHub by using GitHub API. For the successful build you need to:
- generate [new GitHub API token](https://github.com/settings/tokens)
- set `GITHUB_TOKEN` environment variable
```bash
export GITHUB_TOKEN=<your_github_token>
```
- pass the token to the script
```bash
./build.sh --build-args:GITHUB_TOKEN=${GITHUB_TOKEN}
```

Parameter `${GITHUB_TOKEN}` is optional. It's necessary only when exceeding the [limit of GitHub requests](https://developer.github.com/apps/building-github-apps/understanding-rate-limits-for-github-apps/).
## Theia Branch
**`${THEIA_BRANCH}`**
It specifies tag or branch for base Theia. Build script clones Theia sources, switches to that branch/tag, and only then clones Che-Theia.
Parameter `${THEIA_BRANCH}` is optional. If it's not specified, the default value `'master'` will be used.


CI generates several tags of [docker images](https://hub.docker.com/r/eclipse/che-theia/tags). Below is the list of images:

- `eclipse/che-theia:next`
- theia branch: [master](https://github.com/theia-ide/theia/)
- che-theia branch: [master](https://github.com/eclipse/che-theia)
- CI [build job](https://ci.codenvycorp.com/job/che-theia-next/)

- `eclipse/che-theia:7.0.0-next` Che-Theia 7.0.0 with the latest changes
- theia branch: [che-7.0.0](https://github.com/theia-ide/theia/tree/che-7.0.0)
- che-theia branch: [7.0.0](https://github.com/eclipse/che-theia/tree/7.0.0)
- CI [build job](https://ci.codenvycorp.com/job/che-theia-7.0.0-next/)

- `eclipse/che:theia:latest` the latest stable Che-Theia 7.0.0 release
- theia branch: [che-7.0.0](https://github.com/theia-ide/theia/tree/che-7.0.0)
- che-theia tag: [v7.0.0-rc-4.0](https://github.com/eclipse/che-theia/tree/v7.0.0-rc-4.0)


## Theia version

There's a default Theia version set in the script. This version is then injected in all package.jsons.
You can override `THEIA_VERSION` by exporting the env before running the script
**`${THEIA_VERSION}`**

This parameter is used for finding patches. All found patches from `'/patches/${THEIA_VERSION}'` directory will be applied to Theia sources.
You can set `THEIA_VERSION` environment variable and don't pass it to the script when building.
Parameter `${THEIA_VERSION}` is optional. If it's not specified, the default value `'master'` will be used.


## Image Tag

**`${IMAGE_TAG}`**

A newly created docker image will have this version. Passing `'--tag:1.0.0'` to the script will lead to creating `eclipse/che-theia-dev:1.0.0` docker image.

Parameter `${IMAGE_TAG}` is optioal. If it's not specified, the default value `'next'` will be used.
## Theia Git Prefs
**`${THEIA_GIT_REFS}`**
Is used to invalidate docker cache when the current che-theia branch has been changed after last build of the dockerfile. If you are building che-theia from your branch, you have to set refs to `'refs\\/heads\\/${THE_BRANCH_NAME}'`.
This parameter is optional. Default value is `'refs\\/heads\\/master'`.
## Skip Tests
**`--skip-tests`**
## GITHUB_TOKEN
Add this parameter to the build command to have a quick build and to skip running tests in dedicated container.
Once of Theia dependencies calls GitHub API during build to download binaries. It may happen that GitHub API rate limit is exceeded.
As a result build fails. It may not happen at all. If it happens, obtain GitHub API token
By default tests are turned on.
## CDN Support
Expand Down
8 changes: 3 additions & 5 deletions dockerfiles/theia/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ fi
#in mac os 'cp' cannot create destination dir, so create it first
mkdir ${LOCAL_ASSEMBLY_DIR}

echo "Copying ${base_dir}/../../che-theia-init-sources.yml --> ${LOCAL_ASSEMBLY_DIR}/che-theia-init-sources.yml"
cp "${base_dir}/../../che-theia-init-sources.yml" "${LOCAL_ASSEMBLY_DIR}/"
echo "Compresing 'che-theia' --> ${LOCAL_ASSEMBLY_DIR}/che-theia.tar.gz"
cd "${DIR}"/../.. && git ls-files -z -c -o --exclude-standard | xargs -0 tar rvf ${LOCAL_ASSEMBLY_DIR}/che-theia.tar.gz

init --name:theia "$@"

Expand All @@ -47,7 +47,5 @@ if [ -n "${LABEL_CONTENT}" ]; then
BUILD_ARGS+="--label che-plugin.cdn.artifacts=$(echo ${LABEL_CONTENT} | sed 's/ //g') "
echo "Rebuilding with CDN label..."
build
if [ "${BUILD_BRANCH:-}" == "master" ]; then
"${base_dir}"/push-cdn-files-to-akamai.sh
fi
"${base_dir}"/push-cdn-files-to-akamai.sh
fi
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ context('TypeScript', () => {
});
}).then(() => {
// select new folder
cy.get('.theia-app-left > .p-TabBar-content > [title="Explorer"]').click({ force: true }).then(() => {
cy.get('.p-TabBar-content > #shell-tab-explorer-view-container > .p-TabBar-tabIcon').click({ force: true }).then(() => {
cy.get('#files').contains(FOLDER_NAME).click({ force: true });
})
}).then(() => {
Expand Down
2 changes: 1 addition & 1 deletion dockerfiles/theia/e2e/src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"http-server": "0.11.1",
"jquery": "3.3.1",
"json-server": "0.14.0",
"lodash": "4.17.11",
"lodash": "4.17.15",
"minimist": "1.2.0",
"morgan": "1.9.1",
"react": "16.7.0",
Expand Down
1 change: 1 addition & 0 deletions dockerfiles/theia/push-cdn-files-to-akamai.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
base_dir=$(cd "$(dirname "$0")"; pwd)
current_dir=$(pwd)
if [ -z "${AKAMAI_CHE_AUTH:-}" ]; then
echo "CDN files will not be pushed to the Akamai directory since the 'AKAMAI_CHE_AUTH' environment variable is not set"
exit 0
fi

Expand Down
2 changes: 1 addition & 1 deletion extensions/eclipse-che-theia-plugin-ext/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"@theia/core": "next",
"@theia/plugin-ext": "next",
"axios": "0.18.0",
"js-yaml": "3.12.0"
"js-yaml": "3.13.1"
},
"devDependencies": {
"clean-webpack-plugin": "^0.1.19",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
**********************************************************************/

import { MainPluginApiProvider } from '@theia/plugin-ext/lib/common/plugin-ext-api-contribution';
import { RPCProtocol } from '@theia/plugin-ext/lib/api/rpc-protocol';
import { RPCProtocol } from '@theia/plugin-ext/lib/common/rpc-protocol';
import { injectable, interfaces } from 'inversify';
import { PLUGIN_RPC_CONTEXT } from '../common/che-protocol';
import { CheWorkspaceMainImpl } from './che-workspace-main';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
import { CheTask, CheTaskMain, CheTaskService, CheTaskClient, PLUGIN_RPC_CONTEXT } from '../common/che-protocol';
import { RPCProtocol } from '@theia/plugin-ext/lib/api/rpc-protocol';
import { RPCProtocol } from '@theia/plugin-ext/lib/common/rpc-protocol';
import { interfaces, injectable } from 'inversify';
import { TaskExitedEvent } from '@eclipse-che/plugin';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import { interfaces } from 'inversify';
import { VariableRegistry, VariableResolverService } from '@theia/variable-resolver/lib/browser';
import { RPCProtocol } from '@theia/plugin-ext/lib/api/rpc-protocol';
import { RPCProtocol } from '@theia/plugin-ext/lib/common/rpc-protocol';
import { Disposable, MaybePromise } from '@theia/core';
import { PLUGIN_RPC_CONTEXT, CheVariables, CheVariablesMain, Variable } from '../common/che-protocol';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,7 @@ export class ChePluginManager {

try {
await this.cheApiService.stop();
setTimeout(() => {
window.location.reload();
}, 1000);
window.location.href = document.referrer;
} catch (error) {
this.messageService.error(`Unable to restart your workspace. ${error.message}`);
}
Expand Down
Loading

0 comments on commit 40f095b

Please sign in to comment.