-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Get rid of Gitpod layer #4923
Get rid of Gitpod layer #4923
Conversation
Codecov Report
@@ Coverage Diff @@
## main #4923 +/- ##
=========================================
+ Coverage 0 36.18% +36.18%
=========================================
Files 0 16 +16
Lines 0 4068 +4068
=========================================
+ Hits 0 1472 +1472
- Misses 0 2473 +2473
- Partials 0 123 +123
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
It would be great if we could use any of the Go libraries available to avoid distribution dependent binaries |
I agree. We have used go-git in the past and found incompatibilities at the time regarding the global Git config. It's well possible those have been resolved by now. Now I reckon the question is if this way we could use the latest --filter optimisations :) Update after looking at the COMPATIBILITY.md:
Are there any other comprehensive Git libraries we should be looking at? |
46a17cd
to
533584c
Compare
and just push the image instead
e65c69f
to
a340375
Compare
usually the login process would set that, but we're not executing child processes using a login process, but rather run them directly without a login shell.
a340375
to
8e25346
Compare
/hold we really need to test this thoroughly with different images |
/werft run 👍 started the job as gitpod-build-csweichel-image-builder-get-rid-4899.18 |
@csweichel I tested all the examples, gitpod, and even your image-ubuntu repository. Everything works. Just one question, what's the expected behavior in case the gitpod account exists but the UID is different? |
Excellent question. Two ways come to mind:
The first one is clearly much easier to implement. WDYT? |
👍 (right now stays in |
@csweichel awesome. |
LGTM label has been added. Git tree hash: 3d4baa050cf30fbe095186e76fc63c5cc0ba9365
|
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.
Whoa, many thanks @csweichel for taking this on! 💯 🎖️
Epic!! 🎸 (Although I'd have preferred fewer lines of new Go code 🙈 looks a bit scary to my untrained eye, as each new line of code has a non-zero risk-of-new-bug -- regardless of how excellent the developer is!)
Added a few comments on the code. Will now test. 😇
|
||
|
||
USER ROOT | ||
COPY ./gitpod-cli /usr/bin/gp |
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.
This PR removes the need for the Gitpod layer, by moving the user and group creation to supervisor.
What about the gp
CLI? Surely we want to continue installing it as well. (Should at least test that it's still there.)
# Configure user shell | ||
# TODO Remove this in the near future when we do not need ~/.bashrc appends/prepends any more | ||
RUN \ | ||
# REALLY do not print motd | ||
touch ~/.hushlogin && \ | ||
# Configure shell | ||
BASH_RC=~/.bashrc; if [ -f "$BASH_RC" ]; then cp "$BASH_RC" ~/.bashrc-org; else touch ~/.bashrc-org; fi && \ | ||
cat /var/gitpod/gitpod/.bashrc-prepend > "$BASH_RC" && \ | ||
cat ~/.bashrc-org >> "$BASH_RC" && \ | ||
cat /var/gitpod/gitpod/.bashrc-append >> "$BASH_RC" |
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! 😍
|
||
|
||
############################################################################### | ||
########## Gitpod - prepend | ||
############################################################################### | ||
|
||
# Prompt color and bash_completion | ||
export PS1='\[\e]0;\u \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u\[\033[00m\] \[\033[01;34m\]\w \$ \[\033[00m\]' | ||
#source /etc/bash_completion | ||
|
||
# editor config - should be removed when registry facade is default | ||
if [ -z "$EDITOR" ]; then | ||
export EDITOR="gp open -w" | ||
fi | ||
if [ -z "$VISUAL" ]; then | ||
export VISUAL="$EDITOR" | ||
fi | ||
if [ -z "$GIT_EDITOR" ]; then | ||
export GIT_EDITOR="$EDITOR" | ||
fi | ||
|
||
# Workaround Java pre v10 by explicitly setting "-Xmx" for all Hotspot/openJDK VMs | ||
if [ -n "$GITPOD_MEMORY" ]; then | ||
export JAVA_TOOL_OPTIONS="-Xmx${GITPOD_MEMORY}m"; | ||
fi | ||
|
||
# Completion for gp command | ||
. <(gp completion) | ||
# ide cli config - should be removed when registry facade is default | ||
if [ ! -d "/ide/bin/" ]; then | ||
alias open='gp open' | ||
alias code='gp open' | ||
fi | ||
|
||
export GEM_HOME=/workspace/.rvm | ||
export GEM_PATH=$GEM_HOME:$GEM_PATH | ||
export PATH=/workspace/.rvm/bin:$PATH | ||
|
||
export PIPENV_VENV_IN_PROJECT=true | ||
export PIP_USER=yes | ||
export PYTHONUSERBASE=/workspace/.pip-modules | ||
export PATH=$PYTHONUSERBASE/bin:$PATH | ||
unset PIP_TARGET | ||
unset PYTHONPATH | ||
|
||
# Set CARGO_HOME to reside in workspace if: | ||
# - it's RUNTIME (/workspace present) | ||
if [ -d /workspace ]; then | ||
export CARGO_HOME=/workspace/.cargo | ||
export PATH=$CARGO_HOME/bin:$PATH | ||
fi | ||
|
||
export BROWSER="${BROWSER:=gp-preview}" | ||
|
||
############################################################################### | ||
########## Gitpod - prepend | ||
############################################################################### | ||
|
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.
Burn it, burn it all with fire! 🔥🔥🔥
TODO:
-
PS1
prompt gets re-defined anyway so line had no effect - Test that making a new commit from the console is still okay (
EDITOR
vars) - Test that
JAVA_TOOL_OPTIONS
is still defined so that the JVM won't eat up all Gitpod's precious RAM - Test
gp
and its auto-completion - Test
open
andcode
aliases (nice to haves / but not mandatory) -
GEM_HOME=/workspace/.rvm
gets overwritten by nearly all Ruby projects anyway - We want a less crazy-custom Python setup so fine by me
- Test
cargo install
persistence across restarts - I've never liked the
BROWSER
automatic behavior (i.e. "automatically open IDE preview when some specific web servers start") (also did that even work in Code?)
I guess most of these changes are fine, because we want fewer non-standard customizations:
- except for
gp
andJAVA_TOOL_OPTIONS
, which look dangerous and really should be tested - also, big question: is Full Workspace Backup enabled everywhere now? (If yes, it's fine to remove all
/workspace
hacks -- if not, this PR breaks Rust, Python and maybe Ruby package persistence)
Hmm, I can't seem to open any repository in the current deployment 😕 I tried:
|
/werft run 👍 started the job as gitpod-build-csweichel-image-builder-get-rid-4899.20 |
Notes and Questions
|
36533ee
to
05dc5d5
Compare
fdf87d1
to
c5a7b32
Compare
Thanks @jankeromnes and @AlexTugarev for testing this - and sorry for the obvious blunder. I've fixed the "unknown user" issue, added |
bb8f148
to
e7b942d
Compare
New workspaces starting just fine. The one that failed previously doesn't start. How can that issue be permanent? Visiting https://csweichel-image-builder-get-rid-4899.staging.gitpod-dev.com/start/#apricot-dove-rz8cloog |
@AlexTugarev I reckon that's because the "reconciliation loop" of ws-manager-bridge hasn't "stopped" the old workspace yet. It's still stuck in the stopping state from the last attempt |
/hold cancel |
/lgtm |
LGTM label has been added. Git tree hash: 029093ef5eda27ecc17d9e17c08f7eafd83f4445
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: aledbf Associated issue: #4899 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
fixes #4899
This PR removes the need for the Gitpod layer, by moving the user and group creation to supervisor.
How to test
Start workspaces with as many different images you can think of.
Especially interesting: images that don't have a Gitpod user to begin with, e.g. https://github.com/csweichel/test-repo/tree/image-ubuntu
Open questions:
.bashrc
modifications? IMHO that was somewhat of an antipattern to begin with and we should find other ways if need be.