-
Notifications
You must be signed in to change notification settings - Fork 1
feat: allow customizing workspace directory #2
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
Changes from 3 commits
1b861c5
fac790d
dbd1b6f
4c45deb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.PHONY: test | ||
test: | ||
devcontainer features test |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ set -e | |
|
||
CODE_SERVER_INSTALL_ARGS="" | ||
|
||
if [ -n "$VERSION" ]; then | ||
if [[ -n $VERSION ]]; then | ||
CODE_SERVER_INSTALL_ARGS="$CODE_SERVER_INSTALL_ARGS --version=\"$VERSION\"" | ||
fi | ||
|
||
|
@@ -17,12 +17,18 @@ do | |
code-server --install-extension "$extension" | ||
done | ||
|
||
CODE_SERVER_WORKSPACE="$_REMOTE_USER_HOME" | ||
|
||
if [[ -n $WORKSPACE ]]; then | ||
CODE_SERVER_WORKSPACE="$WORKSPACE" | ||
fi | ||
|
||
cat > /usr/local/bin/code-server-entrypoint \ | ||
<< EOF | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
su $_REMOTE_USER -c 'code-server --bind-addr "$HOST:$PORT" \$ARGS' | ||
su $_REMOTE_USER -c 'code-server --bind-addr "$HOST:$PORT" $ARGS "$CODE_SERVER_WORKSPACE"' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moving from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where does ARGS come from and what does it contain? I wonder if we need to worry about quoting and/or newlines? Right now a
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Maybe we need to escape this? (or just drop it altogether) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Gotcha, maybe we could use eval for simplicity?
Used like this:
You can still do something sneaky, like:
But I don't know if we need care? Someone could just as well include a malicious feature? 🤷🏻♂️ The alternative is that we encode supported code-server flags/opts as explicit feature options, which lets us drop ARGS. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TIL of I think the best course of action would be to ensure we support every CLI flag with a feature and drop |
||
EOF | ||
|
||
chmod +x /usr/local/bin/code-server-entrypoint |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
# Optional: Import test library bundled with the devcontainer CLI | ||
source dev-container-features-test-lib | ||
|
||
# Feature-specific tests | ||
check "code-server version" code-server --version | ||
check "code-server running" pgrep -f 'code-server/lib/node.*/code-server' | ||
check "code-server listening" lsof -i "@127.0.0.1:8080" | ||
|
||
check "code-server workspace" grep $'\'code-server.*"/home"\'' < /usr/local/bin/code-server-entrypoint | ||
|
||
# Report results | ||
reportResults |
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.
$_REMOTE_USER_HOME
should always be set