Skip to content

Generate yarn cache with THEIA_VERSION. Generate resolutions to use strict Theia dependencies#10164

Merged
AndrienkoAleksandr merged 15 commits intomasterfrom
fixTheiaImageCreation
Jul 23, 2018
Merged

Generate yarn cache with THEIA_VERSION. Generate resolutions to use strict Theia dependencies#10164
AndrienkoAleksandr merged 15 commits intomasterfrom
fixTheiaImageCreation

Conversation

@AndrienkoAleksandr
Copy link
Copy Markdown
Contributor

What does this PR do?

Generate and apply resolutions to the Theia package.json to use strict Theia dependencies versions.

What issues does this PR fix or reference?

Work around for:
eclipse-theia/theia#2137

Signed-off-by: Oleksandr Andriienko oandriie@redhat.com

…dependency with strict version.

Signed-off-by: Oleksandr Andriienko <oandriie@redhat.com>
@AndrienkoAleksandr AndrienkoAleksandr requested review from a user, benoitf and mmorhun June 23, 2018 10:45
@AndrienkoAleksandr AndrienkoAleksandr changed the title Generate cache with THEIA_VERSION. Generate resolutions for Theia dependencies Generate yarn cache with THEIA_VERSION. Generate resolutions for Theia dependencies Jun 23, 2018
@AndrienkoAleksandr AndrienkoAleksandr changed the title Generate yarn cache with THEIA_VERSION. Generate resolutions for Theia dependencies Generate yarn cache with THEIA_VERSION. Generate resolutions to use strict Theia dependencies Jun 23, 2018
@benoitf benoitf added the status/code-review This issue has a pull request posted for it and is awaiting code review completion by the community. label Jun 23, 2018
ADD https://raw.githubusercontent.com/theia-ide/theia/v${THEIA_VERSION}/examples/browser/package.json /home/theia/package.json
ADD theia-default-package.json /home/default/theia/package.json
ADD versions.sh /home/default/versions.sh
ADD src/versions.sh /home/default/versions.sh
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe not for this PR, but should we store in a directory all files that will go to /home/default so we can use only one ADD instruction, and we don't need to think on adding line each time we require a file ?

./versions.sh /home/default/theia/package.json && \
node resolutions-provider.js /home/theia/package.json /home/default/resolutions.json && \
node resolutions-applier.js /home/default/resolutions.json /home/theia/package.json && \
node resolutions-applier.js /home/default/resolutions.json /home/default/theia/package.json && \
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we can use pattern

node resolution-applier <resolution-file> <file1> <file2> <file3>

const RESOLUTIONS_JSON_PATH = process.argv[2];
const PACKAGE_JSON_PATH = process.argv[3];

const RESOLITIONS = require(RESOLUTIONS_JSON_PATH);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo on RESOLUTIONS (I/U)

const RESOLITIONS = require(RESOLUTIONS_JSON_PATH);
const PACKAGE_JSON = require(PACKAGE_JSON_PATH);

PACKAGE_JSON["resolutions"] = RESOLITIONS;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same typo


const PACKAGE_JSON = require(PACKAGE_JSON_PATH);
const THEIA_VERSION = process.env.THEIA_VERSION;
const THEID_DEP_PREFIX = "@theia/";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it a typo / THEID instead of THEIA ?

@skabashnyuk
Copy link
Copy Markdown
Contributor

@AndrienkoAleksandr @ashumilova Is this work in progress PR?

@AndrienkoAleksandr
Copy link
Copy Markdown
Contributor Author

@skabashnyuk yes it's in progress.

Don't use yarn cache dir on Theia build, use node_modules, like single storage.
Reuse Theia node_modules on default extensions build.
Use extensions json to get list default extensions.

Signed-off-by: Oleksandr Andriienko <oandriie@redhat.com>

ARG GITHUB_TOKEN
ARG THEIA_VERSION=0.4.0-next.b17727c1
ARG THEIA_VERSION=3.12
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's not 0.3.12 ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ops, I build image manually and apply version with help docker arg, and didn't see this mistake.

Signed-off-by: Oleksandr Andriienko <oandriie@redhat.com>
Signed-off-by: Oleksandr Andriienko <oandriie@redhat.com>
@@ -0,0 +1,16 @@
{
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is doing this file ? (in comparison with npmjs where some extensions are deployed ? )

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's file with list default extensions

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't saw this changes, I will check it. add-extension.js use extensions.js script to get default extensions from github or volume, build these extensions and rebuild theia with them. Do you propose doesn't support this stuff?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was suggesting as higlighted by @sunix that if extension is stored on npmjs then we can use npmjs way of grabbing extension.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@benoitf I checked factory extension works with this pr too. I think, if we have released extension we can apply it to the package.json, like it was done by sunix. But in case if we have github link or volume to the source code we can use add-extensions.js script to development purpose. add-extensions.js contains optimization to reuse Theia node_modules. @benoitf What do you think? Like variant I can apply empty extensions.json, like sample. And we will apply machine-extension and che-theia-hosted-plugin-manager-extension later after release on the npm.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AndrienkoAleksandr yes it's nice to keep extensibility with this file but if possible use package.json for released artifacts on npmjs

@AndrienkoAleksandr
Copy link
Copy Markdown
Contributor Author

Applied changes:

  • use extension.json with list default extension;
  • don't use yarn cache, include all dependencies to the node_modules;
  • default extension reuse Theia node_modules;
    After optimization docker image size decreased from more than 3 Gb to less than 900 Mb.

Tested on the openshift.io.

@ashumilova ashumilova mentioned this pull request Jul 11, 2018
20 tasks
# Apply resolution section to the Theia package.json to use strict versions for Theia dependencies
node ${HOME}/resolutions-provider.js ${HOME}/package.json && \
# generate node_modules, should be reused with default extensions
yarn --global-folder ${HOME}/node_modules/ --cache-folder ${HOME}/node_modules/ && \
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how does it behave inside the container when running a new yarn command in for example /tmp/my-project

does yarn will download again all dependencies as cache will be different location ?
(for example if user create a new Theia plugin and want to compile it)

should we use yarn config set or .yarnrc file

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@benoitf I think the easiest way to increase docker image size it's a using yarn cache clean command. What do you think?

yarn && \
yarn theia build && \
# Install Theia plugin generator
#==TODO== add after generator-theia-plugin release
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix bug with using not "Sync exists" function. Reinstall wget, download files by https links doensn't work without this action after update alpine image.
Copy link
Copy Markdown
Contributor

@mmorhun mmorhun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

node ${HOME}/resolutions-provider.js ${HOME}/package.json && \
# generate node_modules, should be reused with default extensions
yarn --global-folder ${HOME}/node_modules/ --cache-folder ${HOME}/node_modules/ && \
rm -rf ${HOME}/extensions && \
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need this step?

yarn --global-folder ${HOME}/node_modules/ --cache-folder ${HOME}/node_modules/ && \
rm -rf ${HOME}/extensions && \
# Add default Theia extensions
node ${HOME}/add-extensions.js && \
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can remove this script after invoking.


with native docker:

```
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think given version in the example won't work because plugin model is released in 0.3.12. Please add note and correct example.

function checkoutRepo(path, checkoutTarget) {
try {
if (!checkoutTarget) {
checkoutTarget = 'master';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we shouldn't checkout at all if checkoutTarget is not set.

{
"name": "theia-machines-extension",
"source": "https://github.com/eclipse/che-theia-machines-plugin.git",
"version": "0.3.12",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rename to version to branch ot whatever because it is actually checkout argument.

@mmorhun mmorhun mentioned this pull request Jul 17, 2018
Signed-off-by: Oleksandr Andriienko <oandriie@redhat.com>
Signed-off-by: Oleksandr Andriienko <oandriie@redhat.com>
Signed-off-by: Oleksandr Andriienko <oandriie@redhat.com>
@AndrienkoAleksandr
Copy link
Copy Markdown
Contributor Author

Hmm... Sometimes docker build fail:

warning "@theia/metrics > @theia/application-manager > font-awesome-webpack@0.0.5-beta.2" has unmet peer dependency "font-awesome@>=4.3.0".
[4/4] Building fresh packages...
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
error /home/theia/node_modules/electron: Command failed.
Exit code: 1
Command: node install.js
Arguments:
Directory: /home/theia/node_modules/electron
Output:
Downloading SHASUMS256.txt
Error: socket hang up
/home/theia/node_modules/electron/install.js:47
  throw err
  ^

Error: socket hang up
    at createHangUpError (_http_client.js:331:15)
    at TLSSocket.socketOnEnd (_http_client.js:423:23)
    at emitNone (events.js:111:20)
    at TLSSocket.emit (events.js:208:7)
    at endReadableNT (_stream_readable.js:1064:12)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)

I need take a look...

fi && \
# install remaining packages
apk add --no-cache make gcc g++ python git bash supervisor && \
apk add --no-cache make gcc g++ python git bash supervisor curl && \
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI curl is installed few lines before

Signed-off-by: Oleksandr Andriienko <oandriie@redhat.com>
@AndrienkoAleksandr
Copy link
Copy Markdown
Contributor Author

AndrienkoAleksandr commented Jul 23, 2018

Checked failing build:

Error: socket hang up
    at createHangUpError (_http_client.js:331:15)
    at TLSSocket.socketOnEnd (_http_client.js:423:23)
    at emitNone (events.js:111:20)
    at TLSSocket.emit (events.js:208:7)
    at endReadableNT (_stream_readable.js:1064:12)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)

Today I build 5 times and everything is OK. In Friday 20 was unstable github, so I think it was core reason of failing:
https://status.github.com/messages#2018-07-20

Copy link
Copy Markdown
Contributor

@benoitf benoitf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm travelling today so approving to not block process ;-)

@AndrienkoAleksandr AndrienkoAleksandr merged commit 88add6e into master Jul 23, 2018
@AndrienkoAleksandr AndrienkoAleksandr deleted the fixTheiaImageCreation branch July 23, 2018 08:31
@benoitf benoitf removed the status/code-review This issue has a pull request posted for it and is awaiting code review completion by the community. label Jul 23, 2018
@benoitf benoitf added this to the 6.9.0 milestone Jul 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants