-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update .gitpod.yml to use Java 21 by default #373
Conversation
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.
Also, has any testing been done with this setup?
I applied desired changes but now getting a new error: I dont think that this error is just because of updation in gitpod.yml file but still trying to find what am I missing here. After this error , when I use java -version it gives me the correct version : |
One quick fix is to revert change to add back If reverting does not work then maybe (I am not 100% sure unless we have tried) we should try to config the dependencies we will need using a custom Dockerfile called |
Yes, even after reverting the change and adding the curl back, I’m still encountering the same error. The error seems to persist regardless of the changes, and I am unable to pinpoint the exact cause. I have checked that Java 21 was successfully installed, as confirmed by the java -version output. I still suspect that the issue might not be entirely related to the recent changes in the gitpod.yml file, but I'm continuing to investigate |
As mentioned in #374 (comment) @timja prefers to use Dockerfile for the Gitpod configuration. Would you be willing to adapt this PR with that change in mind? |
Regarding your bug, you may want to add the required dependencies via both Java (https://www.gitpod.io/docs/introduction/languages/java) and JavaScript (https://www.gitpod.io/docs/introduction/languages/javascript using a Dockerfile instead. |
In case you are not aware of already the
is not a Java dependency but a JavaScript dependency. |
.gitpod.yml
Outdated
- init: mvn install -P quick-build | ||
- init: | | ||
curl -s "https://get.sdkman.io" | bash | ||
echo "sdkman_auto_answer=true" > $HOME/.sdkman/etc/config |
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.
Just curious, is this line L4:
echo "sdkman_auto_answer=true" > $HOME/.sdkman/etc/config
really necessary?
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.
Yes, that line is necessary because without it, it prompts you to confirm whether you want to use Java 21 as the default version. By setting sdkman_auto_answer=true, it automatically answers "yes" to this prompt, making the setup seamless without requiring manual input.
Yes , I'm aware of that |
Yes, I’ve started adapting the PR to use a Dockerfile for the Gitpod configuration, as mentioned in #374. |
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.
Please follow https://www.gitpod.io/guides/custom-java-distribution-on-gitpod
The dockerfile approach looks to be the best
Added a dockerfile , still the same error is coming: |
May I ask how are you testing your new Gitpod environment? Could you provide some details about the steps you have taken? |
I’ve been testing the new Gitpod environment by configuring the Dockerfile to install the required versions of Java and Node.js, and adjusting the gitpod.yml file to use it. During the process, I ran into some issues that required trial and error, so I created a separate branch in my fork to test all the changes before merging them. I hope this isn’t considered a bad practice, but it helped ensure everything works as expected. |
But how do you run the tests on Gitpod locally? |
To test the changes, I made modifications to the files locally and then pushed the changes to my branch. After that, I opened the branch directly in Gitpod, which automatically triggered the build process. During the build, all dependencies were installed at the start, and that’s when I encountered the error in the terminal. |
I see, let me see if I can reproduce your issues |
I have tweaked your code a bit in https://github.com/krisstern/design-library-plugin/tree/java21bydefault and have run everything again but I did not encounter any failures or errors. In fact, the following is what I see: gp tasks attach 5fc6e2e1-1fbf-4a0d-bc8d-7dccf606b092
gitpod /workspace/design-library-plugin (java21bydefault) $ gp tasks attach 5fc6e2e1-1fbf-4a0d-bc8d-7dccf606b092
HISTFILE=/workspace/.gitpod/cmd-1 history -r; {
gp ports await 8080 && gp url 8080 && gp preview $(gp url 8080)/jenkins/
}
gitpod /workspace/design-library-plugin (java21bydefault) $ HISTFILE=/workspace/.gitpod/cmd-1 history -r; {
> gp ports await 8080 && gp url 8080 && gp preview $(gp url 8080)/jenkins/
> }
Awaiting port 8080... ok
https://8080-krisstern-designlibrary-msaey2xybvr.ws-us117.gitpod.io
gitpod /workspace/design-library-plugin (java21bydefault) $ java --version
Picked up JAVA_TOOL_OPTIONS: -XX:+UseContainerSupport -XX:ActiveProcessorCount=1
openjdk 21.0.4 2024-07-16 LTS
OpenJDK Runtime Environment Temurin-21.0.4+7 (build 21.0.4+7-LTS)
OpenJDK 64-Bit Server VM Temurin-21.0.4+7 (build 21.0.4+7-LTS, mixed mode, sharing)
gitpod /workspace/design-library-plugin (java21bydefault) $ node --version
v20.18.1 |
The only major difference is that the .gitpod/Dockerfile I have is as follows: FROM gitpod/workspace-full
ARG MAVEN_VERSION=3.9.9
ARG NODE_VERSION=20.18.1
# Install Java 21.0.4-tem and Node.js v20.18.1
RUN brew install gh && \
bash -c ". /home/gitpod/.sdkman/bin/sdkman-init.sh && sdk install maven ${MAVEN_VERSION} && sdk default maven ${MAVEN_VERSION} && \
sdk install java 21.0.4-tem && \
sdk default java 21.0.4-tem" && \
bash -c "source $HOME/.nvm/nvm.sh && nvm install ${NODE_VERSION} \
&& nvm use ${NODE_VERSION} && nvm alias default ${NODE_VERSION}"
# Ensure nvm uses the default version on every new terminal session
RUN echo "nvm use default &>/dev/null" >> ~/.bashrc.d/51-nvm-fix |
But I will have to admit I may not need to have "mvn" installed... so you may want to clean that up a bit |
And you may also want to set the Java JDK version as an |
@krisstern Thanks for the updates. I suspected there might be a configuration issue in my VS Code in gitpod, so I switched to IntelliJ IDEA, and it worked. Now, both your updates and my approach are running without errors. Could you let me know which one you think we should proceed with for the final code? |
Yeah, for VSCode you will need to configure something additional like the |
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.
For the .gitpod/Dockerfile
file, can we use ARG
for both the Java JDK version and the Node.js version?
Sure , updating the Dockerfile with the latest node version ( earlier it was 20.18.1 ) |
.gitpod/Dockerfile
Outdated
@@ -0,0 +1,19 @@ | |||
FROM gitpod/workspace-full:latest | |||
|
|||
USER gitpod |
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.
I am wondering what is this for and do we really need this? I tried without this config and everything worked as expected.
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.
They are used to specify a base image but ig Gitpod already uses these settings by default, so they can be removed without issue.
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.
I think we can run as root (user) by default, since we are using Gitpod this would not be too risky
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.
Yes , right . I am removing both of these lines and will check again on gitpod just for surity.
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.
Wait, I meant for the USER gitpod
line only
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.
I think they have some formatting issue on GitHub, so if I comment on a line plesae only pay attention to the last line. This is a known issue with GitHub.
.gitpod/Dockerfile
Outdated
@@ -1,7 +1,3 @@ | |||
FROM gitpod/workspace-full:latest |
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.
Please add this line back
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.
Yes , even I ran without this and faced some error to load with default image only , adding it back .
I've tested the changes, and everything is working fine now. Please let me know if any further modifications are needed |
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.
@SohamJuneja Just tested your branch on Gitpod and it worked. Thanks for all the hard work put into this PR!
Thanks a lot for your guidance too! @krisstern @timja |
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.
Thanks!
Fixes #367
Testing done
Submitter checklist