Skip to content

Merge wiptheia dockerfile with Che Theia IDE dockerfile#10148

Merged
mmorhun merged 4 commits intomasterfrom
CHE-10124
Jun 26, 2018
Merged

Merge wiptheia dockerfile with Che Theia IDE dockerfile#10148
mmorhun merged 4 commits intomasterfrom
CHE-10124

Conversation

@mmorhun
Copy link
Copy Markdown
Contributor

@mmorhun mmorhun commented Jun 22, 2018

Signed-off-by: Mykola Morhun mmorhun@redhat.com

What does this PR do?

Combines features of witheia docker image with Che one.
Removes unneeded user and sudo from the image.
Drops support for Theia extensions vie env variable. Now thay must be added on docker image build phase.

What issues does this PR fix or reference?

#10124

Signed-off-by: Mykola Morhun <mmorhun@redhat.com>
@mmorhun mmorhun self-assigned this Jun 22, 2018
@benoitf benoitf added status/code-review This issue has a pull request posted for it and is awaiting code review completion by the community. kind/task Internal things, technical debt, and to-do tasks to be performed. labels Jun 22, 2018
@mmorhun
Copy link
Copy Markdown
Contributor Author

mmorhun commented Jun 22, 2018

This PR uses next version of Theia in the image because we don't have released Theia modules with plugin-ext extension. Also patched (for the next version) extensions were used. I added ==TODO==s what should be fixed after the module release.

It is open for discussions.

@benoitf
Copy link
Copy Markdown
Contributor

benoitf commented Jun 22, 2018

hello, could you clarify the 'uneeded user' ?
with the changes, this image is working on che.openshift.io ?

@AndrienkoAleksandr
Copy link
Copy Markdown
Contributor

Maybe we should use next with hash commit instead of next version?

@mmorhun
Copy link
Copy Markdown
Contributor Author

mmorhun commented Jun 22, 2018

@benoitf Yes. I see no pint in having it in the image. I've just checked it on docker and openshift with machines extension - and it works fine (with next versions of course)

@benoitf
Copy link
Copy Markdown
Contributor

benoitf commented Jun 22, 2018

when you say "openshift", is it openshift.io ?

@mmorhun
Copy link
Copy Markdown
Contributor Author

mmorhun commented Jun 22, 2018

It is local ocp

Signed-off-by: Mykola Morhun <mmorhun@redhat.com>
rm -rf /tmp/* /var/cache/apk/*

# Packages which will be included into default build of Theia
ADD theia-default-package.json ${HOME}/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.

as we're adding all files into ${HOME}
maybe we could use a single ADD instruction for everything that goes into /home/theia
(instead of one for package.json, one for versions.sh, one for add-extensions.js and one for start.sh

we could have folders like

src/home/theia --> /home/theia
src/etc/ ---> /etc/

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.

To me it is better to keep it as is because that ADD instructions appears when target file is needed. For example:

ADD src/versions.sh ${HOME}/versions.sh
RUN ${HOME}/versions.sh && rm ${HOME}/versions.sh

We add, use and finally remove file. No need to search whole dockerfile and think about context (who else could use or modify or require it).

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 adds useless extra lines/layers
if you store files in dedicated folders then you're expecting their location inside the image so reading the Dockerfile is easier. And of course, you don't need to bother where this file has been added.

Also note that the file that you're removing is not also really removed from layers.

@mmorhun
Copy link
Copy Markdown
Contributor Author

mmorhun commented Jun 26, 2018

I updated this PR. Tested on docker and openshift.io.
Review again please.

WORKDIR ${HOME}
ADD supervisord.conf /etc/
ADD src/start.sh ${HOME}/start.sh
RUN touch /var/log/supervisord.log && chmod g+rwX /var/log/supervisord.log && chgrp 0 /var/log/supervisord.log
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.

RUN instruction should be appended to the previous

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 think it will impact how easy to read this dockerfile is. But ok, I'll move it.

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.

@mmorhun I would say that workspace should start as fast as possible (minimal set of layers, best size as possible)

# ==TODO== add after generator-theia-plugin release
# npm install -g yo @wiptheia/generator-theia-plugin
# Change permissions to allow editing of files for openshift user
RUN find ${HOME} -exec sh -c "chgrp 0 {}; chmod g+rwX {}" \;
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.

RUN instruction should be merged with the previous RUN instruction
having two RUN instructions with one changing permission is duplicating the layer for nothing

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.

image is almost 1GB, IMHO there are layers that need to be skipped

@ghost
Copy link
Copy Markdown

ghost commented Jun 26, 2018

@mmorhun I'd combine all RUN instructions if possible and have one ADD instruction that adds all files and scripts to one directory from which you can then consume them in a Dockerfile

USE_LOCAL_GIT=true \
HOME=/home/theia

RUN apk update && apk add --no-cache make gcc g++ python git openssh bash supervisor jq && \
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.

on a side note, I notice that you're installing openssh but can we really connect through ssh ?

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.

Yeah, good catch. It is result of merge. Will remove it.

@benoitf
Copy link
Copy Markdown
Contributor

benoitf commented Jun 26, 2018

on a side note, is it possible to make GITHUB_TOKEN optional ?
it seems it is mandatory to build the docker image while it should only be used if defined

@mmorhun
Copy link
Copy Markdown
Contributor Author

mmorhun commented Jun 26, 2018

No, it is not mandatory. One could provide it as a build arg.

@benoitf
Copy link
Copy Markdown
Contributor

benoitf commented Jun 26, 2018

@mmorhun
If I don't export GITHUB_TOKEN to a valid token before launching ./build.sh
I got

error An unexpected error occurred: "/home/theia/node_modules/vscode-ripgrep: Command failed.
Exit code: 1
Command: sh
Arguments: -c node ./lib/postinstall.js
Directory: /home/theia/node_modules/vscode-ripgrep
Output:
Downloading ripgrep failed: Error: Request failed with code 401".

(it's like it provides an empty value token)

@ghost
Copy link
Copy Markdown

ghost commented Jun 26, 2018

@benoitf this is a known limitation of Theia

@benoitf
Copy link
Copy Markdown
Contributor

benoitf commented Jun 26, 2018

@eivantsov I don't see how it's a limitation of theia ?

I can clone theia, build theia and run theia without defining GITHUB_TOKEN
while here, the Dockerfile is defining GITHUB_TOKEN as env var so theia will try to use this empty token if I don't specify it through a build arg.

What I wanted was:

  • ok I share my network with many ppl building theia, OK I need to add GITHUB_TOKEN
  • simple case: I try to build the Dockerfile, first guy on network to do that, it should work without grabbing a token from github in order to set GITHUB_TOKEN

@ghost
Copy link
Copy Markdown

ghost commented Jun 26, 2018

Yes, Theia will use an empty token and build may be a success unless you hit access rate on Github. At least it worked for me this way.

Everyone had such an issue when building Theia. Once the entire office started building Theia and we quickly hit the limit from one IP.

Btw, do we still need GITHUB_TOKEN after eclipse-theia/theia#2091?

@mmorhun
Copy link
Copy Markdown
Contributor Author

mmorhun commented Jun 26, 2018

@eivantsov seems yes. I've tried next version and the problem was there.

@ghost
Copy link
Copy Markdown

ghost commented Jun 26, 2018

We may remove GitHub token arg, but this way there are NO guarantees that the image build won't fail in CI.

@benoitf
Copy link
Copy Markdown
Contributor

benoitf commented Jun 26, 2018

@eivantsov @mmorhun my problem is not with providing GITHUB_TOKEN which is working fine
it's that I shouldn't be forced to provide it if the network is not hitting rate API limit on github.

@ghost
Copy link
Copy Markdown

ghost commented Jun 26, 2018

@benoitf I don't know a good way to know in advance if or not vscode-ripgrep fails that's why GITHUB_TOKEN was added

As the image is built mostly by CI it wasn't a problem.

If you have a better way to build Theia and make one of its components not to download anything from GitHub, we will all appreciate it.

@benoitf
Copy link
Copy Markdown
Contributor

benoitf commented Jun 26, 2018

curl https://api.github.com/rate_limit ?

@benoitf
Copy link
Copy Markdown
Contributor

benoitf commented Jun 26, 2018

BTW I'm not trying to argue that GITHUB_TOKEN is a bad idea and that it doesn't solve an issue. just that it seems it's forcing ppl to give that parameter even if they don't require it.

with curl https://api.github.com/rate_limit you can check the limit rate and probably you can see if it will fail or not. In that case we could say : Please define GITHUB_TOKEN to make the build OK.

@ghost
Copy link
Copy Markdown

ghost commented Jun 26, 2018

Thanks so much. This will of course add complexity to a Dockerfile. An additional script?

@benoitf
Copy link
Copy Markdown
Contributor

benoitf commented Jun 26, 2018

yes maybe we can split long RUN instructions to small shell scripts to be more readable.
RUN fork-theia && compile-theia && update-extensions

I'm fine with all solutions as long as I may not be forced to give GITHUB_TOKEN if not required

Signed-off-by: Mykola Morhun <mmorhun@redhat.com>
@mmorhun mmorhun requested a review from ashumilova as a code owner June 26, 2018 14:36
@mmorhun
Copy link
Copy Markdown
Contributor Author

mmorhun commented Jun 26, 2018

So, we can split it, but I added comments to the sections and finally it doesn't look huge and unreadable.

# Add Theia extensions
#==TODO== replace with Eclipse official version after Theia release
#git clone https://github.com/eclipse/che-theia-hosted-plugin-manager-extension /tmp/hosted-plugin-extension && \
git clone https://github.com/mmorhun/che-theia-hosted-plugin-manager-extension /tmp/hosted-plugin-extension && \
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 the difference between mmorhun/che-theia-hosted-plugin-manager-extension and https://github.com/eclipse/che-theia-hosted-plugin-manager-extension ? could it just be a branch of main repo ?

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.

Yes, sure.

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.

Done

yarn theia build && \
# Install Theia plugin generator
#==TODO== add after generator-theia-plugin release
#npm install -g yo @wiptheia/generator-theia-plugin && \
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.

you think we shouldn't include the wip package for now ?

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 think we need release it first. Do not want to download wiptheia core and 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.

ah yes I forgot to push changes that use @theia/plugin
let's keep commented as you made 👍

# Grant permissions for modifying supervisor log file
touch /var/log/supervisord.log && chmod g+rwX /var/log/supervisord.log && chgrp 0 /var/log/supervisord.log

WORKDIR ${HOME}
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.

(not important) could we move WORKDIR at the top of the file before RUN instruction so we can reuse that layer every time

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.

No problem

ARG THEIA_VERSION=0.3.10
ENV USE_LOCAL_GIT=true \
GITHUB_TOKEN=${GITHUB_TOKEN} \
ARG THEIA_VERSION=0.4.0-next.b17727c1
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.

why using a specific version of next instead of next ?
we may want to include all upstream theia fixes on nightlies

Copy link
Copy Markdown
Contributor Author

@mmorhun mmorhun Jun 26, 2018

Choose a reason for hiding this comment

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

So you want to use next?

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 do not mind

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.

Just to be sure we have working image (I tested it on both docker and oso infras)

Copy link
Copy Markdown
Contributor

@AndrienkoAleksandr AndrienkoAleksandr Jun 26, 2018

Choose a reason for hiding this comment

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

It will be confused when we move back to the strict Theia version, but dockerhub save "next" tag. @benoitf What do you think? Somebody can try to use it, but it won't be next any more. And if we have next tag we should update it every night.

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 I would think to have a real "nightly" based on "next" and a fixed version as suggested by @mmorhun

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.

we can merge and iterate later on the changes

Signed-off-by: Mykola Morhun <mmorhun@redhat.com>
@mmorhun mmorhun merged commit 44681e8 into master Jun 26, 2018
@mmorhun mmorhun deleted the CHE-10124 branch June 26, 2018 15:58
@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 Jun 26, 2018
@benoitf benoitf added this to the 6.8.0 milestone Jun 26, 2018
@benoitf
Copy link
Copy Markdown
Contributor

benoitf commented Jun 27, 2018

FYI I created #10205 for improvements

@mmorhun
Copy link
Copy Markdown
Contributor Author

mmorhun commented Jun 27, 2018

Thanks

hbhargav pushed a commit to hbhargav/che that referenced this pull request Dec 5, 2018
…10148)

* CHE-10124: Merge wiptheia dockerfile with Che Theia IDE dockerfile

Signed-off-by: Mykola Morhun <mmorhun@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/task Internal things, technical debt, and to-do tasks to be performed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants