Generate yarn cache with THEIA_VERSION. Generate resolutions to use strict Theia dependencies#10164
Conversation
…dependency with strict version. Signed-off-by: Oleksandr Andriienko <oandriie@redhat.com>
dockerfiles/theia/Dockerfile
Outdated
| 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 |
There was a problem hiding this comment.
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 ?
dockerfiles/theia/Dockerfile
Outdated
| ./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 && \ |
There was a problem hiding this comment.
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); |
| const RESOLITIONS = require(RESOLUTIONS_JSON_PATH); | ||
| const PACKAGE_JSON = require(PACKAGE_JSON_PATH); | ||
|
|
||
| PACKAGE_JSON["resolutions"] = RESOLITIONS; |
|
|
||
| const PACKAGE_JSON = require(PACKAGE_JSON_PATH); | ||
| const THEIA_VERSION = process.env.THEIA_VERSION; | ||
| const THEID_DEP_PREFIX = "@theia/"; |
There was a problem hiding this comment.
is it a typo / THEID instead of THEIA ?
|
@AndrienkoAleksandr @ashumilova Is this work in progress PR? |
|
@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>
dockerfiles/theia/Dockerfile
Outdated
|
|
||
| ARG GITHUB_TOKEN | ||
| ARG THEIA_VERSION=0.4.0-next.b17727c1 | ||
| ARG THEIA_VERSION=3.12 |
There was a problem hiding this comment.
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 @@ | |||
| { | |||
There was a problem hiding this comment.
what is doing this file ? (in comparison with npmjs where some extensions are deployed ? )
There was a problem hiding this comment.
It's file with list default extensions
There was a problem hiding this comment.
my question is: what's the difference with https://github.com/eclipse/che/blob/db0cb63926b0110e05d4ba6d78912f1f4d856f95/dockerfiles/theia/src/package.json#L14 ?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
I was suggesting as higlighted by @sunix that if extension is stored on npmjs then we can use npmjs way of grabbing extension.
There was a problem hiding this comment.
@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.
There was a problem hiding this comment.
@AndrienkoAleksandr yes it's nice to keep extensibility with this file but if possible use package.json for released artifacts on npmjs
|
Applied changes:
Tested on the openshift.io. |
dockerfiles/theia/Dockerfile
Outdated
| # 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/ && \ |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
@benoitf I think the easiest way to increase docker image size it's a using yarn cache clean command. What do you think?
dockerfiles/theia/Dockerfile
Outdated
| yarn && \ | ||
| yarn theia build && \ | ||
| # Install Theia plugin generator | ||
| #==TODO== add after generator-theia-plugin release |
There was a problem hiding this comment.
TODO can be removed
https://www.npmjs.com/package/@theia/generator-plugin
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.
dockerfiles/theia/Dockerfile
Outdated
| 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 && \ |
There was a problem hiding this comment.
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 && \ |
There was a problem hiding this comment.
We can remove this script after invoking.
|
|
||
| with native docker: | ||
|
|
||
| ``` |
There was a problem hiding this comment.
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'; |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
Please rename to version to branch ot whatever because it is actually checkout argument.
|
Hmm... Sometimes docker build fail: I need take a look... |
dockerfiles/theia/Dockerfile
Outdated
| 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 && \ |
There was a problem hiding this comment.
FYI curl is installed few lines before
Signed-off-by: Oleksandr Andriienko <oandriie@redhat.com>
|
Checked failing build: Today I build 5 times and everything is OK. In Friday 20 was unstable github, so I think it was core reason of failing: |
benoitf
left a comment
There was a problem hiding this comment.
I'm travelling today so approving to not block process ;-)
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