From 11d793296805253a2f4d289f5e7741fe3bcfbfa4 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 3 Jun 2020 11:41:13 -0400 Subject: [PATCH] Stop bundling libraries in release - Instead we now use CentOS 7 for the static build to guarantee that we only depend on libc v2.17 - For macOS we now pull in a static node binary and bundle that instead. --- .github/workflows/ci.yaml | 6 ++-- .gitignore | 1 + ci/build/build-standalone-release.sh | 21 ----------- ci/build/code-server.sh | 7 +--- ci/build/test-standalone-release.sh | 3 +- ci/container/Dockerfile | 2 +- ci/container/arm64/Dockerfile | 53 ---------------------------- ci/container/arm64/README.md | 6 ---- ci/container/centos/Dockerfile | 22 ++++++++++++ ci/steps/release-packages.sh | 5 +++ doc/npm.md | 2 +- src/node/entry.ts | 18 ---------- 12 files changed, 35 insertions(+), 111 deletions(-) delete mode 100644 ci/container/arm64/Dockerfile delete mode 100644 ci/container/arm64/README.md create mode 100644 ci/container/centos/Dockerfile diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 4696df2e..f3f3e72c 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -55,7 +55,7 @@ jobs: name: npm-package path: ./release-npm-package - name: Run ./ci/steps/release-packages.sh - uses: ./ci/container + uses: ./ci/container/centos with: args: ./ci/steps/release-packages.sh - name: Upload release artifacts @@ -75,7 +75,7 @@ jobs: name: npm-package path: ./release-npm-package - name: Run ./ci/steps/release-packages.sh - uses: ./ci/container/arm64 + uses: ./ci/container/centos with: args: ./ci/steps/release-packages.sh - name: Upload release artifacts @@ -94,8 +94,6 @@ jobs: with: name: npm-package path: ./release-npm-package - - run: brew unlink node@12 - - run: brew install node - run: ./ci/steps/release-packages.sh env: # Otherwise we get rate limited when fetching the ripgrep binary. diff --git a/.gitignore b/.gitignore index 5c10b876..424cb9e7 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ release-packages/ release-gcp/ release-images/ node_modules +node-* diff --git a/ci/build/build-standalone-release.sh b/ci/build/build-standalone-release.sh index 2556e44b..df6cdc56 100755 --- a/ci/build/build-standalone-release.sh +++ b/ci/build/build-standalone-release.sh @@ -17,14 +17,6 @@ main() { mkdir -p "$RELEASE_PATH/bin" rsync ./ci/build/code-server.sh "$RELEASE_PATH/bin/code-server" rsync "$node_path" "$RELEASE_PATH/lib/node" - if [[ $OS == "linux" ]]; then - bundle_dynamic_lib libstdc++ - bundle_dynamic_lib libgcc_s - elif [[ $OS == "macos" ]]; then - bundle_dynamic_lib libicui18n - bundle_dynamic_lib libicuuc - bundle_dynamic_lib libicudata - fi ln -s "./bin/code-server" "$RELEASE_PATH/code-server" ln -s "./lib/node" "$RELEASE_PATH/node" @@ -33,17 +25,4 @@ main() { yarn --production --frozen-lockfile } -bundle_dynamic_lib() { - local lib_name="$1" - local lib_path - - if [[ $OS == "linux" ]]; then - lib_path="$(ldd "$RELEASE_PATH/lib/node" | grep "$lib_name" | awk '{print $3 }')" - elif [[ $OS == "macos" ]]; then - lib_path="$(otool -L "$RELEASE_PATH/lib/node" | grep "$lib_name" | awk '{print $1 }')" - fi - - cp "$lib_path" "$RELEASE_PATH/lib" -} - main "$@" diff --git a/ci/build/code-server.sh b/ci/build/code-server.sh index 62b59a0f..eae38000 100755 --- a/ci/build/code-server.sh +++ b/ci/build/code-server.sh @@ -12,10 +12,10 @@ _realpath() { # See https://github.com/cdr/code-server/issues/1537 if [ "$(uname)" = "Darwin" ]; then - # We read the symlink, which may be relative from $1. script="$1" if [ -L "$script" ]; then while [ -L "$script" ]; do + # We recursively read the symlink, which may be relative from $script. script="$(readlink "$script")" cd "$(dirname "$script")" done @@ -32,9 +32,4 @@ _realpath() { } ROOT="$(dirname "$(dirname "$(_realpath "$0")")")" -if [ "$(uname)" = "Linux" ]; then - export LD_LIBRARY_PATH="$ROOT/lib:${LD_LIBRARY_PATH-}" -elif [ "$(uname)" = "Darwin" ]; then - export DYLD_LIBRARY_PATH="$ROOT/lib:${DYLD_LIBRARY_PATH-}" -fi exec "$ROOT/lib/node" "$ROOT" "$@" diff --git a/ci/build/test-standalone-release.sh b/ci/build/test-standalone-release.sh index 0344ea39..488a057a 100755 --- a/ci/build/test-standalone-release.sh +++ b/ci/build/test-standalone-release.sh @@ -15,7 +15,8 @@ main() { ./release-standalone/bin/code-server --extensions-dir "$EXTENSIONS_DIR" --install-extension ms-python.python local installed_extensions installed_extensions="$(./release-standalone/bin/code-server --extensions-dir "$EXTENSIONS_DIR" --list-extensions 2>&1)" - if [[ $installed_extensions != "ms-python.python" ]]; then + if [[ "$installed_extensions" != "info Using config file ~/.config/code-server/config.yaml +ms-python.python" ]]; then echo "Unexpected output from listing extensions:" echo "$installed_extensions" exit 1 diff --git a/ci/container/Dockerfile b/ci/container/Dockerfile index 8612f84d..fa3b16dc 100644 --- a/ci/container/Dockerfile +++ b/ci/container/Dockerfile @@ -43,7 +43,7 @@ RUN ARCH="$(dpkg --print-architecture)" && \ # rm -R shellcheck* # Install Go dependencies -RUN ARCH="$(dpkg --print-architecture)" && \ +RUN ARCH="$(uname -m | sed 's/x86_64/amd64/; s/aarch64/arm64/')" && \ curl -fsSL "https://dl.google.com/go/go1.14.3.linux-$ARCH.tar.gz" | tar -C /usr/local -xz ENV PATH=/usr/local/go/bin:/root/go/bin:$PATH ENV GO111MODULE=on diff --git a/ci/container/arm64/Dockerfile b/ci/container/arm64/Dockerfile deleted file mode 100644 index 705365bc..00000000 --- a/ci/container/arm64/Dockerfile +++ /dev/null @@ -1,53 +0,0 @@ -FROM debian:9 - -RUN apt-get update - -# Needed for debian repositories added below. -RUN apt-get install -y curl gnupg - -# Installs node. -RUN curl -fsSL https://deb.nodesource.com/setup_14.x | bash - && \ - apt-get install -y nodejs - -# Installs yarn. -RUN curl -fsSL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \ - echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \ - apt-get update && apt-get install -y yarn - -# Installs VS Code build deps. -RUN apt-get install -y build-essential \ - libsecret-1-dev \ - libx11-dev \ - libxkbfile-dev - -# Installs envsubst. -RUN apt-get install -y gettext-base - -# Misc build dependencies. -RUN apt-get install -y git rsync unzip - -# We need latest jq from debian buster for date support. -RUN ARCH="$(dpkg --print-architecture)" && \ - curl -fsSOL http://http.us.debian.org/debian/pool/main/libo/libonig/libonig5_6.9.1-1_$ARCH.deb && \ - dpkg -i libonig*.deb && \ - curl -fsSOL http://http.us.debian.org/debian/pool/main/j/jq/libjq1_1.5+dfsg-2+b1_$ARCH.deb && \ - dpkg -i libjq*.deb && \ - curl -fsSOL http://http.us.debian.org/debian/pool/main/j/jq/jq_1.5+dfsg-2+b1_$ARCH.deb && \ - dpkg -i jq*.deb && rm *.deb - -# Installs shellcheck. -# Unfortunately coredumps on debian:8 so disabled for now. -#RUN curl -fsSL https://github.com/koalaman/shellcheck/releases/download/v0.7.1/shellcheck-v0.7.1.linux.$(uname -m).tar.xz | \ -# tar -xJ && \ -# mv shellcheck*/shellcheck /usr/local/bin && \ -# rm -R shellcheck* - -# Install Go dependencies -RUN ARCH="$(dpkg --print-architecture)" && \ - curl -fsSL "https://dl.google.com/go/go1.14.3.linux-$ARCH.tar.gz" | tar -C /usr/local -xz -ENV PATH=/usr/local/go/bin:/root/go/bin:$PATH -ENV GO111MODULE=on -RUN go get mvdan.cc/sh/v3/cmd/shfmt -RUN go get github.com/goreleaser/nfpm/cmd/nfpm - -RUN curl -fsSL https://get.docker.com | sh diff --git a/ci/container/arm64/README.md b/ci/container/arm64/README.md deleted file mode 100644 index 388572ca..00000000 --- a/ci/container/arm64/README.md +++ /dev/null @@ -1,6 +0,0 @@ -# arm64 - -Unfortunately there is no arm64 build of `debian:8` so -we need to use `debian:9` instead. - -This is just an exact copy of [../Dockerfile](../Dockerfile) with the base image change. diff --git a/ci/container/centos/Dockerfile b/ci/container/centos/Dockerfile new file mode 100644 index 00000000..43ad9431 --- /dev/null +++ b/ci/container/centos/Dockerfile @@ -0,0 +1,22 @@ +FROM centos:7 + +RUN curl -sL https://rpm.nodesource.com/setup_14.x | bash - && \ + yum install -y nodejs && + npm install -g yarn + +RUN yum groupinstall -y 'Development Tools' +RUN yum install -y python2 libsecret-devel libX11-devel libxkbfile-devel + +RUN npm config set python python2 + +RUN yum install -y epel-release && yum install -y jq +RUN yum install -y rsync + +# Copied from ../Dockerfile +# Install Go dependencies +RUN ARCH="$(uname -m | sed 's/x86_64/amd64/; s/aarch64/arm64/')" && \ + curl -fsSL "https://dl.google.com/go/go1.14.3.linux-$ARCH.tar.gz" | tar -C /usr/local -xz +ENV PATH=/usr/local/go/bin:/root/go/bin:$PATH +ENV GO111MODULE=on +RUN go get mvdan.cc/sh/v3/cmd/shfmt +RUN go get github.com/goreleaser/nfpm/cmd/nfpm diff --git a/ci/steps/release-packages.sh b/ci/steps/release-packages.sh index bb1dcf5f..cdfcf914 100755 --- a/ci/steps/release-packages.sh +++ b/ci/steps/release-packages.sh @@ -4,6 +4,11 @@ set -euo pipefail main() { cd "$(dirname "$0")/../.." + if [[ "$OSTYPE" == darwin* ]]; then + curl -L https://nodejs.org/dist/v14.4.0/node-v14.4.0-darwin-x64.tar.gz | tar -xz + PATH="$PATH:node-v14.4.0-darwin-x64/bin" + fi + # https://github.com/actions/upload-artifact/issues/38 tar -xzf release-npm-package/package.tar.gz diff --git a/doc/npm.md b/doc/npm.md index 18d9fc5e..a612ba8c 100644 --- a/doc/npm.md +++ b/doc/npm.md @@ -20,7 +20,7 @@ sudo apt-get install -y \ ```bash sudo yum groupinstall -y 'Development Tools' -sudo yum config-manager --set-enabled PowerTools +sudo yum config-manager --set-enabled PowerTools # unnecessary on CentOS 7 sudo yum install -y python2 libsecret-devel libX11-devel libxkbfile-devel npm config set python python2 ``` diff --git a/src/node/entry.ts b/src/node/entry.ts index 53f99d10..a7d8663d 100644 --- a/src/node/entry.ts +++ b/src/node/entry.ts @@ -122,25 +122,7 @@ const main = async (args: Args, cliArgs: Args, configArgs: Args): Promise } } -function trimLDLibraryPath(): void { - let ldVar: string - if (process.platform === "linux") { - ldVar = "LD_LIBRARY_PATH" - } else if (process.platform === "darwin") { - ldVar = "DYLD_LIBRARY_PATH" - } else { - return - } - - // Removes the leading path added by ./ci/build/code-server.sh to use our bundled - // dynamic libraries. See ci/build/build-standalone-release.sh - // This is required to avoid child processes using our bundled libraries. - process.env[ldVar] = process.env[ldVar]?.replace(path.dirname(process.execPath) + ":", "") -} - async function entry(): Promise { - trimLDLibraryPath() - const tryParse = async (): Promise<[Args, Args, Args]> => { try { const cliArgs = parse(process.argv.slice(2))