Skip to content
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

Support HTTP BasicAuth for authentication if $AUTH_USER is set #7143

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Build scripts for custom Golden Helix build of code-server
  • Loading branch information
gaberudy committed Dec 29, 2024
commit cee70311b54ef0a225195fcf8e092575a8e066c2
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
**
!release-packages
!ci
!release-standalone
!startup.sh
!install_locales.sh
51 changes: 51 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
ARG SERVER_VERSION=20241223_895aa2908981
FROM registry.goldenhelix.com/gh/server:${SERVER_VERSION}

USER root

# Install various locales to support users from different regions
COPY ./install_locales.sh /tmp/install_locales.sh
RUN bash /tmp/install_locales.sh

# Copy the release-standalone directory
COPY ./release-standalone /opt/code-server
COPY ./startup.sh /opt/code-server/startup.sh

# Remove the existing node binary and create symlink to the system node
RUN rm -f /opt/code-server/lib/node && \
ln -s /opt/node/bin/node /opt/code-server/lib/node && \
chmod +x /opt/code-server/startup.sh

# Set the environment variables
ARG LANG='en_US.UTF-8'
ARG LANGUAGE='en_US:en'
ARG LC_ALL='en_US.UTF-8'
ARG START_XFCE4=1
ARG TZ='Etc/UTC'
ENV HOME=/home/ghuser \
SHELL=/bin/bash \
USERNAME=ghuser \
LANG=$LANG \
LANGUAGE=$LANGUAGE \
LC_ALL=$LC_ALL \
TZ=$TZ \
AUTH_USER=ghuser \
CODE_SERVER_SESSION_SOCKET=/home/ghuser/.config/code-server/code-server-ipc.sock \
PASSWORD=ghuserpassword \
PORT=8080

### Ports and user
EXPOSE $PORT
WORKDIR $HOME
USER 1000

RUN mkdir -p $HOME/.config/code-server && \
echo "bind-addr: 0.0.0.0:8080" > $HOME/.config/code-server/config.yaml && \
echo "auth: password" >> $HOME/.config/code-server/config.yaml && \
echo "password: \${PASSWORD}" >> $HOME/.config/code-server/config.yaml && \
echo "cert: true" >> $HOME/.config/code-server/config.yaml


RUN mkdir -p $HOME/Workspace/Documents

ENTRYPOINT ["/opt/code-server/startup.sh"]
45 changes: 45 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash
Copy link
Member

Choose a reason for hiding this comment

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

This Docker image seems unrelated to the auth changes, could we remove it from this PR? Happy to read about it in another PR/issue, but at first glance I am not sure it is something we should be maintaining here.

Copy link
Author

Choose a reason for hiding this comment

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

Yea, I didn't meant to include this.


# Build a Golden Helix docker image for code-server with changes to support App Streaming on VSWarehouse

# Follow the directions under [CONTRIBUTING.md](docs/CONTRIBUTING.md) to build the image

# git submodule update --init
# quilt push -a
# npm install
# npm run build
# VERSION=4.96.2 npm run build:vscode
# npm run release

# VERSION=4.96.2 npm run package
# cd release
# npm install --omit=dev
# cd ..
# npm run release:standalone

export VERSION=4.96.2

export SERVER_VERSION=20241223_895aa2908981

# Ensure we're in the correct directory
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$SCRIPT_DIR"

# Temporarily move the bundled node out of the way
if [ -f "release-standalone/lib/node" ]; then
mv release-standalone/lib/node ./node
fi

echo "PWD: $PWD"

docker build --no-cache \
--build-arg SERVER_VERSION=${SERVER_VERSION} \
-t registry.goldenhelix.com/gh/code-server:${VERSION} .

# Move the bundled node back
if [ -f "./node" ]; then
mv ./node release-standalone/lib/node
fi

# Run like
# docker run -it -p 8081:8080 -e PASSWORD=your_secure_password123 -e PORT=8080 registry.goldenhelix.com/gh/code-server:20241223_895aa2908981 /home/ghuser/Workspace/
15 changes: 15 additions & 0 deletions extensions.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
github.copilot
Copy link
Member

Choose a reason for hiding this comment

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

Could we omit this file? Seems unrelated to code-server itself.

Copy link
Author

Choose a reason for hiding this comment

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

yes, unintended

github.copilot-chat
hashicorp.terraform
ms-python.debugpy
ms-python.python
ms-python.vscode-pylance
ms-toolsai.jupyter
ms-toolsai.jupyter-keymap
ms-toolsai.jupyter-renderers
ms-toolsai.vscode-jupyter-cell-tags
ms-toolsai.vscode-jupyter-slideshow
ms-vscode-remote.remote-containers
stkb.rewrap
streetsidesoftware.code-spell-checker
redhat.vscode-yaml
12 changes: 12 additions & 0 deletions install_locales.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
Copy link
Member

Choose a reason for hiding this comment

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

Also seems unrelated to this particular PR.

Copy link
Author

Choose a reason for hiding this comment

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

yes, unintended

# *GH* selected major languages for space and time
LOCALES="de_DE fr_FR it_IT es_ES en_GB nl_NL sv_SE pl_PL fr_BE nl_BE de_AT da_DK fi_FI el_GR en_IE pt_PT cs_CZ hu_HU ro_RO bg_BG ja_JP zh_CN ko_KR hi_IN ru_RU"

echo "Installing languages"
apt-get update
apt-get install -y \
locales locales-all
for LOCALE in ${LOCALES}; do
echo "Generating Locale for ${LOCALE}"
localedef -i ${LOCALE} -f UTF-8 ${LOCALE}.UTF-8
done
44 changes: 44 additions & 0 deletions install_system_extensions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash
Copy link
Member

Choose a reason for hiding this comment

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

Same here

Copy link
Author

Choose a reason for hiding this comment

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

yes, unintended


EXTENSIONS_FILE="./extensions.txt"
CODE_SERVER="./release-standalone/bin/code-server"
EXTENSIONS_DIR="~/.local/share/code-server/extensions"
TARGET_DIR="./release-standalone/lib/vscode/extensions"

# Check if code-server exists
if [ ! -f "$CODE_SERVER" ]; then
echo "Error: code-server not found at $CODE_SERVER"
exit 1
fi

# Create target directory if it doesn't exist
mkdir -p "$TARGET_DIR"

# Read extensions file line by line
while IFS= read -r extension || [ -n "$extension" ]; do
# Skip empty lines and comments
if [[ -z "$extension" || "$extension" =~ ^# ]]; then
continue
fi

echo "Installing extension: $extension"

# Install the extension
$CODE_SERVER --install-extension "$extension"

if [ $? -ne 0 ]; then
echo "Warning: Failed to install $extension"
continue
fi

echo "Copying extension files to standalone directory"
# Use cp -R with expanded source path
if ! eval "cp -R $EXTENSIONS_DIR/${extension}* $TARGET_DIR/"; then
echo "Warning: Failed to copy $extension to standalone directory"
fi

echo "Completed processing $extension"
echo "----------------------------------------"
done < "$EXTENSIONS_FILE"

echo "All extensions processed"
8 changes: 5 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
"safe-buffer": "^5.2.1",
"safe-compare": "^1.1.4",
"semver": "^7.5.4",
"tslib": "^2.8.1",
Copy link
Member

Choose a reason for hiding this comment

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

What was this added for? We have no direct dependency on tslib, do we?

Copy link
Author

Choose a reason for hiding this comment

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

I will remove it, but I had a packaging issue without it.

"ws": "^8.14.2",
"xdg-basedir": "^4.0.0"
},
Expand Down
27 changes: 27 additions & 0 deletions startup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash
Copy link
Member

Choose a reason for hiding this comment

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

Unrelated to the PR?

Copy link
Author

Choose a reason for hiding this comment

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

Yes


# Try to set up the private (per user) User Data folder
set +e
mkdir -p $HOME/Workspace/Documents/$USERNAME/code-server
export XDG_DATA_HOME=$HOME/Workspace/Documents/$USERNAME
set -e

echo 'export PS1="$USERNAME:\w\$ "' >> $HOME/.bashrc

# Set the default project folder
DEFAULT_PROJECT_FOLDER="$HOME/Workspace/"

# Use the provided PROJECT_FOLDER or default to DEFAULT_PROJECT_FOLDER
STARTING_FOLDER="${PROJECT_FOLDER:-$DEFAULT_PROJECT_FOLDER}"

# Your script logic here
echo "Starting in folder: $STARTING_FOLDER"

/opt/code-server/bin/code-server \
--disable-telemetry \
--disable-update-check \
--disable-workspace-trust \
--locale=$LANG \
--welcome-text="Welcome to your Golden Helix VSCode environment" \
--ignore-last-opened \
$STARTING_FOLDER
Loading