diff --git a/.dockerignore b/.dockerignore index 9bcce7a80897..659d188bec22 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,3 +1,6 @@ ** !release-packages !ci +!release-standalone +!startup.sh +!install_locales.sh \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000000..39b7579f8538 --- /dev/null +++ b/Dockerfile @@ -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"] diff --git a/build.sh b/build.sh new file mode 100755 index 000000000000..92100752d210 --- /dev/null +++ b/build.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +# 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/ diff --git a/extensions.txt b/extensions.txt new file mode 100644 index 000000000000..bb499ddce72b --- /dev/null +++ b/extensions.txt @@ -0,0 +1,15 @@ +github.copilot +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 diff --git a/install_locales.sh b/install_locales.sh new file mode 100644 index 000000000000..320faa28a82a --- /dev/null +++ b/install_locales.sh @@ -0,0 +1,12 @@ +#!/bin/bash +# *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 \ No newline at end of file diff --git a/install_system_extensions.sh b/install_system_extensions.sh new file mode 100755 index 000000000000..52a69be0dbc2 --- /dev/null +++ b/install_system_extensions.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +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" \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 3779af901516..fe5ad5c90604 100644 --- a/package-lock.json +++ b/package-lock.json @@ -28,6 +28,7 @@ "safe-buffer": "^5.2.1", "safe-compare": "^1.1.4", "semver": "^7.5.4", + "tslib": "^2.8.1", "ws": "^8.14.2", "xdg-basedir": "^4.0.0" }, @@ -5631,9 +5632,10 @@ } }, "node_modules/tslib": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.7.0.tgz", - "integrity": "sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA==" + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", + "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", + "license": "0BSD" }, "node_modules/type-check": { "version": "0.4.0", diff --git a/package.json b/package.json index e91feacc035e..febd67725616 100644 --- a/package.json +++ b/package.json @@ -86,6 +86,7 @@ "safe-buffer": "^5.2.1", "safe-compare": "^1.1.4", "semver": "^7.5.4", + "tslib": "^2.8.1", "ws": "^8.14.2", "xdg-basedir": "^4.0.0" }, diff --git a/startup.sh b/startup.sh new file mode 100644 index 000000000000..cb2d2e4cb78e --- /dev/null +++ b/startup.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +# 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 \ No newline at end of file