|
| 1 | +# Copyright (c) 2024 Gitpod GmbH. All rights reserved. |
| 2 | +# Licensed under the GNU Affero General Public License (AGPL). |
| 3 | +# See License.AGPL.txt in the project root for license information. |
| 4 | +FROM gitpod/openvscode-server-linux-build-agent:focal-x64 as code_builder |
| 5 | + |
| 6 | +ENV TRIGGER_REBUILD 1 |
| 7 | + |
| 8 | +ENV PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 |
| 9 | +ENV ELECTRON_SKIP_BINARY_DOWNLOAD=1 |
| 10 | +ENV VSCODE_ARCH=x64 |
| 11 | +ENV NPM_REGISTRY=https://registry.npmjs.org |
| 12 | + |
| 13 | +ARG CODE_COMMIT |
| 14 | +ARG CODE_QUALITY |
| 15 | +ARG CODE_VERSION |
| 16 | + |
| 17 | +RUN sudo mkdir -m 0755 -p /etc/apt/keyrings |
| 18 | +RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg |
| 19 | + |
| 20 | +RUN if dpkg --compare-versions "$CODE_VERSION" "ge" "1.90"; then \ |
| 21 | + NODE_VERSION=20; \ |
| 22 | + else \ |
| 23 | + NODE_VERSION=18; \ |
| 24 | + fi && \ |
| 25 | + echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_VERSION.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list |
| 26 | +RUN apt-get update && apt-get install -y nodejs |
| 27 | + |
| 28 | +RUN mkdir /gp-code \ |
| 29 | + && cd /gp-code \ |
| 30 | + && git init \ |
| 31 | + && git remote add origin https://github.com/gitpod-io/openvscode-server \ |
| 32 | + && git fetch origin $CODE_COMMIT --depth=1 \ |
| 33 | + && git reset --hard FETCH_HEAD |
| 34 | +WORKDIR /gp-code |
| 35 | + |
| 36 | +RUN apt-get install -y pkg-config dbus xvfb libgtk-3-0 libxkbfile-dev libkrb5-dev libgbm1 rpm \ |
| 37 | + && cp build/azure-pipelines/linux/xvfb.init /etc/init.d/xvfb \ |
| 38 | + && chmod +x /etc/init.d/xvfb \ |
| 39 | + && update-rc.d xvfb defaults \ |
| 40 | + && service xvfb start \ |
| 41 | + # Start dbus session |
| 42 | + && mkdir -p /var/run/dbus |
| 43 | + |
| 44 | +# Disable v8 cache used by yarn v1.x, refs https://github.com/nodejs/node/issues/51555 |
| 45 | +ENV DISABLE_V8_COMPILE_CACHE=1 |
| 46 | + |
| 47 | +# ENV npm_config_arch=x64 |
| 48 | +RUN mkdir -p .build \ |
| 49 | + && npm config set registry "$NPM_REGISTRY" \ |
| 50 | + && npm ci |
| 51 | + |
| 52 | +# check that the provided codeVersion is the correct one for the given codeCommit |
| 53 | +RUN commitVersion=$(cat package.json | jq -r .version) \ |
| 54 | + && if [ "$commitVersion" != "$CODE_VERSION" ]; then echo "Code version mismatch: $commitVersion != $CODE_VERSION"; exit 1; fi |
| 55 | + |
| 56 | +# update product.json |
| 57 | +RUN nameShort=$(jq --raw-output '.nameShort' product.json) && \ |
| 58 | + nameLong=$(jq --raw-output '.nameLong' product.json) && \ |
| 59 | + if [ "$CODE_QUALITY" = "insider" ]; then \ |
| 60 | + nameShort="$nameShort - Insiders" \ |
| 61 | + nameLong="$nameLong - Insiders" \ |
| 62 | + ; fi && \ |
| 63 | + setQuality="setpath([\"quality\"]; \"$CODE_QUALITY\")" && \ |
| 64 | + setNameShort="setpath([\"nameShort\"]; \"$nameShort\")" && \ |
| 65 | + setNameLong="setpath([\"nameLong\"]; \"$nameLong\")" && \ |
| 66 | + setSegmentKey="setpath([\"segmentKey\"]; \"untrusted-dummy-key\")" && \ |
| 67 | + jqCommands="${setQuality} | ${setNameShort} | ${setNameLong} | ${setSegmentKey}" && \ |
| 68 | + cat product.json | jq "${jqCommands}" > product.json.tmp && \ |
| 69 | + mv product.json.tmp product.json && \ |
| 70 | + jq '{quality,nameLong,nameShort}' product.json |
| 71 | + |
| 72 | +RUN npm run gulp compile-build |
| 73 | +RUN npm run gulp extensions-ci |
| 74 | +RUN npm run gulp minify-vscode-reh |
| 75 | +RUN npm run gulp vscode-web-min-ci |
| 76 | +RUN npm run gulp vscode-reh-linux-x64-min-ci |
| 77 | + |
| 78 | +# config for first layer needed by blobserve |
| 79 | +# this custom urls will be then replaced by blobserve. |
| 80 | +# Check pkg/blobserve/blobserve.go, `inlineVars` method |
| 81 | +RUN cp /vscode-web/out/vs/gitpod/browser/workbench/workbench.html /vscode-web/index.html \ |
| 82 | +&& cp /vscode-web/out/vs/gitpod/browser/workbench/callback.html /vscode-web/callback.html \ |
| 83 | +&& sed -i -e "s/{{VERSION}}/$CODE_QUALITY-$CODE_COMMIT/g" /vscode-web/index.html |
| 84 | + |
| 85 | +# cli config: alises to gitpod-code |
| 86 | +RUN cp /vscode-reh-linux-x64/bin/remote-cli/gitpod-code /vscode-reh-linux-x64/bin/remote-cli/code \ |
| 87 | +&& cp /vscode-reh-linux-x64/bin/remote-cli/gitpod-code /vscode-reh-linux-x64/bin/remote-cli/gp-code \ |
| 88 | +&& cp /vscode-reh-linux-x64/bin/remote-cli/gitpod-code /vscode-reh-linux-x64/bin/remote-cli/open |
| 89 | + |
| 90 | +# grant write permissions for built-in extensions |
| 91 | +RUN chmod -R ugo+w /vscode-reh-linux-x64/extensions |
| 92 | + |
| 93 | +FROM scratch |
| 94 | +# copy static web resources in first layer to serve from blobserve |
| 95 | +COPY --from=code_builder --chown=33333:33333 /vscode-web/ /ide/ |
| 96 | +COPY --from=code_builder --chown=33333:33333 /vscode-reh-linux-x64/ /ide/ |
| 97 | + |
| 98 | +ARG CODE_VERSION |
| 99 | +ARG CODE_COMMIT |
| 100 | +LABEL "io.gitpod.ide.version"=$CODE_VERSION |
| 101 | +LABEL "io.gitpod.ide.commit"=$CODE_COMMIT |
0 commit comments