Skip to content

Commit 2fbbe5d

Browse files
authored
Fix stable code build (#20310)
* Fix stable code build * update leeway dep
1 parent 00b2a76 commit 2fbbe5d

File tree

4 files changed

+160
-2
lines changed

4 files changed

+160
-2
lines changed

.github/workflows/code-build.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ jobs:
6969
- [ ] test `gp open` and `gp preview`
7070
- [ ] test open in VS Code Desktop, check `gp open` and `gp preview` in task/user terminals
7171
- [ ] telemetry data like `vscode_extension_gallery` is collected in [Segment](https://app.segment.com/gitpod/sources/staging_trusted/debugger)
72+
- [ ] test using `ubuntu 18` is working well, [example repo](https://github.com/jeanp413/test-gp-prebuild/tree/jp/damaged-aardwolf)
7273
7374
### Preview status
7475
gitpod:summary

components/ide/code/BUILD.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ packages:
2525
- codeQuality
2626
- codeVersion
2727
config:
28-
dockerfile: leeway.Dockerfile
28+
dockerfile: leeway.nightly.Dockerfile
2929
metadata:
3030
helm-component: workspace.codeImage
3131
buildArgs:

components/ide/code/leeway.Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ RUN npm run gulp compile-build \
134134
# config for first layer needed by blobserve
135135
# this custom urls will be then replaced by blobserve.
136136
# Check pkg/blobserve/blobserve.go, `inlineVars` method
137-
RUN cp /vscode-web/out/vs/gitpod/browser/workbench/workbench.html /vscode-web/index.html \
137+
RUN cp /vscode-web/out/vs/gitpod/browser/workbench/workbench.esm.html /vscode-web/index.html \
138138
&& cp /vscode-web/out/vs/gitpod/browser/workbench/callback.html /vscode-web/callback.html \
139139
&& sed -i -e "s/{{VERSION}}/$CODE_QUALITY-$CODE_COMMIT/g" /vscode-web/index.html
140140

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
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:centos7-devtoolset8-x64 as dependencies_builder
5+
6+
ENV TRIGGER_REBUILD 1
7+
8+
ARG CODE_COMMIT
9+
10+
RUN mkdir /gp-code \
11+
&& cd /gp-code \
12+
&& git init \
13+
&& git remote add origin https://github.com/gitpod-io/openvscode-server \
14+
&& git fetch origin $CODE_COMMIT --depth=1 \
15+
&& git reset --hard FETCH_HEAD
16+
WORKDIR /gp-code/remote
17+
18+
RUN npm ci
19+
20+
FROM ubuntu:22.04 as code_builder
21+
22+
ARG DEBIAN_FRONTEND=noninteractive
23+
24+
ENV TRIGGER_REBUILD 1
25+
26+
ENV PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
27+
ENV ELECTRON_SKIP_BINARY_DOWNLOAD=1
28+
ENV VSCODE_ARCH=x64
29+
ENV NPM_REGISTRY=https://registry.npmjs.org
30+
ENV NODE_VERSION=20
31+
32+
ARG CODE_COMMIT
33+
ARG CODE_QUALITY
34+
ARG CODE_VERSION
35+
36+
# Latest stable git
37+
RUN apt-get update && apt-get install -y software-properties-common
38+
RUN add-apt-repository ppa:git-core/ppa -y
39+
40+
RUN apt-get update && apt-get install -y \
41+
apt-transport-https \
42+
ca-certificates \
43+
curl \
44+
file \
45+
git \
46+
gnome-keyring \
47+
iproute2 \
48+
libfuse2 \
49+
libgconf-2-4 \
50+
libgdk-pixbuf2.0-0 \
51+
libgl1 \
52+
libgtk-3.0 \
53+
libsecret-1-dev \
54+
libssl-dev \
55+
libx11-dev \
56+
libx11-xcb-dev \
57+
libxkbfile-dev \
58+
locales \
59+
lsb-release \
60+
lsof \
61+
python3-pip \
62+
sudo \
63+
wget \
64+
xvfb \
65+
tzdata \
66+
unzip \
67+
jq
68+
69+
# Set python3 as default
70+
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 1
71+
RUN python --version
72+
73+
# Check compiler toolchain
74+
RUN gcc --version
75+
RUN g++ --version
76+
77+
RUN sudo mkdir -m 0755 -p /etc/apt/keyrings
78+
RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
79+
80+
RUN 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
81+
RUN apt-get update && apt-get install -y nodejs
82+
83+
RUN mkdir /gp-code \
84+
&& cd /gp-code \
85+
&& git init \
86+
&& git remote add origin https://github.com/gitpod-io/openvscode-server \
87+
&& git fetch origin $CODE_COMMIT --depth=1 \
88+
&& git reset --hard FETCH_HEAD
89+
WORKDIR /gp-code
90+
91+
RUN apt-get install -y pkg-config dbus xvfb libgtk-3-0 libxkbfile-dev libkrb5-dev libgbm1 rpm \
92+
&& cp build/azure-pipelines/linux/xvfb.init /etc/init.d/xvfb \
93+
&& chmod +x /etc/init.d/xvfb \
94+
&& update-rc.d xvfb defaults \
95+
&& service xvfb start \
96+
# Start dbus session
97+
&& mkdir -p /var/run/dbus
98+
99+
ENV npm_config_arch=x64
100+
RUN mkdir -p .build \
101+
&& npm config set registry "$NPM_REGISTRY" \
102+
&& npm ci
103+
104+
# copy remote dependencies build in dependencies_builder image
105+
RUN rm -rf remote/node_modules/
106+
COPY --from=dependencies_builder /gp-code/remote/node_modules/ /gp-code/remote/node_modules/
107+
108+
# check that the provided codeVersion is the correct one for the given codeCommit
109+
RUN commitVersion=$(cat package.json | jq -r .version) \
110+
&& if [ "$commitVersion" != "$CODE_VERSION" ]; then echo "Code version mismatch: $commitVersion != $CODE_VERSION"; exit 1; fi
111+
112+
# update product.json
113+
RUN nameShort=$(jq --raw-output '.nameShort' product.json) && \
114+
nameLong=$(jq --raw-output '.nameLong' product.json) && \
115+
if [ "$CODE_QUALITY" = "insider" ]; then \
116+
nameShort="$nameShort - Insiders" \
117+
nameLong="$nameLong - Insiders" \
118+
; fi && \
119+
setQuality="setpath([\"quality\"]; \"$CODE_QUALITY\")" && \
120+
setNameShort="setpath([\"nameShort\"]; \"$nameShort\")" && \
121+
setNameLong="setpath([\"nameLong\"]; \"$nameLong\")" && \
122+
setSegmentKey="setpath([\"segmentKey\"]; \"untrusted-dummy-key\")" && \
123+
jqCommands="${setQuality} | ${setNameShort} | ${setNameLong} | ${setSegmentKey}" && \
124+
cat product.json | jq "${jqCommands}" > product.json.tmp && \
125+
mv product.json.tmp product.json && \
126+
jq '{quality,nameLong,nameShort}' product.json
127+
128+
RUN npm run gulp compile-build
129+
RUN npm run gulp extensions-ci
130+
RUN npm run gulp minify-vscode-reh
131+
RUN npm run gulp vscode-web-min-ci
132+
RUN npm run gulp vscode-reh-linux-x64-min-ci
133+
134+
# config for first layer needed by blobserve
135+
# this custom urls will be then replaced by blobserve.
136+
# Check pkg/blobserve/blobserve.go, `inlineVars` method
137+
RUN cp /vscode-web/out/vs/gitpod/browser/workbench/workbench.html /vscode-web/index.html \
138+
&& cp /vscode-web/out/vs/gitpod/browser/workbench/callback.html /vscode-web/callback.html \
139+
&& sed -i -e "s/{{VERSION}}/$CODE_QUALITY-$CODE_COMMIT/g" /vscode-web/index.html
140+
141+
# cli config: alises to gitpod-code
142+
RUN cp /vscode-reh-linux-x64/bin/remote-cli/gitpod-code /vscode-reh-linux-x64/bin/remote-cli/code \
143+
&& cp /vscode-reh-linux-x64/bin/remote-cli/gitpod-code /vscode-reh-linux-x64/bin/remote-cli/gp-code \
144+
&& cp /vscode-reh-linux-x64/bin/remote-cli/gitpod-code /vscode-reh-linux-x64/bin/remote-cli/open
145+
146+
# grant write permissions for built-in extensions
147+
RUN chmod -R ugo+w /vscode-reh-linux-x64/extensions
148+
149+
FROM scratch
150+
# copy static web resources in first layer to serve from blobserve
151+
COPY --from=code_builder --chown=33333:33333 /vscode-web/ /ide/
152+
COPY --from=code_builder --chown=33333:33333 /vscode-reh-linux-x64/ /ide/
153+
154+
ARG CODE_VERSION
155+
ARG CODE_COMMIT
156+
LABEL "io.gitpod.ide.version"=$CODE_VERSION
157+
LABEL "io.gitpod.ide.commit"=$CODE_COMMIT

0 commit comments

Comments
 (0)