-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy pathleeway.Dockerfile
100 lines (81 loc) · 4.13 KB
/
leeway.Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# Copyright (c) 2020 Gitpod GmbH. All rights reserved.
# Licensed under the GNU Affero General Public License (AGPL).
# See License-AGPL.txt in the project root for license information.
FROM gitpod/openvscode-server-linux-build-agent:centos7-devtoolset8-x64 as dependencies_builder
ARG CODE_COMMIT
RUN mkdir /gp-code \
&& cd /gp-code \
&& git init \
&& git remote add origin https://github.com/gitpod-io/openvscode-server \
&& git fetch origin $CODE_COMMIT --depth=1 \
&& git reset --hard FETCH_HEAD
WORKDIR /gp-code
RUN yarn --cwd remote --frozen-lockfile --network-timeout 180000
FROM gitpod/openvscode-server-linux-build-agent:bionic-x64 as code_builder
ARG CODE_COMMIT
ARG CODE_QUALITY
ARG NODE_VERSION=16.16.0
ARG NVM_DIR="/root/.nvm"
RUN mkdir -p $NVM_DIR \
&& curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | sh \
&& . $NVM_DIR/nvm.sh \
&& nvm alias default $NODE_VERSION
ENV PATH=$NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH
ENV PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
ENV ELECTRON_SKIP_BINARY_DOWNLOAD=1
RUN mkdir /gp-code \
&& cd /gp-code \
&& git init \
&& git remote add origin https://github.com/gitpod-io/openvscode-server \
&& git fetch origin $CODE_COMMIT --depth=1 \
&& git reset --hard FETCH_HEAD
WORKDIR /gp-code
ENV npm_config_arch=x64
RUN yarn --frozen-lockfile --network-timeout 180000
# copy remote dependencies build in dependencies_builder image
RUN rm -rf remote/node_modules/
COPY --from=dependencies_builder /gp-code/remote/node_modules/ /gp-code/remote/node_modules/
# update product.json
RUN nameShort=$(jq --raw-output '.nameShort' product.json) && \
nameLong=$(jq --raw-output '.nameLong' product.json) && \
if [ "$CODE_QUALITY" = "insider" ]; then \
nameShort="$nameShort - Insiders" \
nameLong="$nameLong - Insiders" \
; fi && \
setQuality="setpath([\"quality\"]; \"$CODE_QUALITY\")" && \
setNameShort="setpath([\"nameShort\"]; \"$nameShort\")" && \
setNameLong="setpath([\"nameLong\"]; \"$nameLong\")" && \
jqCommands="${setQuality} | ${setNameShort} | ${setNameLong}" && \
cat product.json | jq "${jqCommands}" > product.json.tmp && \
mv product.json.tmp product.json && \
jq '{quality,nameLong,nameShort}' product.json
RUN yarn --cwd extensions compile \
&& yarn gulp vscode-web-min \
&& yarn gulp vscode-reh-linux-x64-min
# config for first layer needed by blobserve
# we also remove `static/` from resource urls as that's needed by blobserve,
# this custom urls will be then replaced by blobserve.
# Check pkg/blobserve/blobserve.go, `inlineVars` method
RUN cp /vscode-web/out/vs/gitpod/browser/workbench/workbench.html /vscode-web/index.html \
&& cp /vscode-web/out/vs/gitpod/browser/workbench/callback.html /vscode-web/callback.html \
&& sed -i -e 's#static/##g' /vscode-web/index.html \
&& sed -i -e "s/{{VERSION}}/$CODE_QUALITY-$CODE_COMMIT/g" /vscode-web/index.html
# cli config: alises to gitpod-code
RUN cp /vscode-reh-linux-x64/bin/remote-cli/gitpod-code /vscode-reh-linux-x64/bin/remote-cli/code \
&& cp /vscode-reh-linux-x64/bin/remote-cli/gitpod-code /vscode-reh-linux-x64/bin/remote-cli/gp-code \
&& cp /vscode-reh-linux-x64/bin/remote-cli/gitpod-code /vscode-reh-linux-x64/bin/remote-cli/open
# grant write permissions for built-in extensions
RUN chmod -R ugo+w /vscode-reh-linux-x64/extensions
FROM scratch
# copy static web resources in first layer to serve from blobserve
COPY --from=code_builder --chown=33333:33333 /vscode-web/ /ide/
COPY --from=code_builder --chown=33333:33333 /vscode-reh-linux-x64/ /ide/
COPY --chown=33333:33333 startup.sh supervisor-ide-config.json components-ide-code-codehelper--app/codehelper /ide/
ENV GITPOD_ENV_APPEND_PATH=/ide/bin/remote-cli:
# editor config
ENV GITPOD_ENV_SET_EDITOR=/ide/bin/remote-cli/gitpod-code
ENV GITPOD_ENV_SET_VISUAL="$GITPOD_ENV_SET_EDITOR"
ENV GITPOD_ENV_SET_GP_OPEN_EDITOR="$GITPOD_ENV_SET_EDITOR"
ENV GITPOD_ENV_SET_GIT_EDITOR="$GITPOD_ENV_SET_EDITOR --wait"
ENV GITPOD_ENV_SET_GP_PREVIEW_BROWSER="/ide/bin/remote-cli/gitpod-code --preview"
ENV GITPOD_ENV_SET_GP_EXTERNAL_BROWSER="/ide/bin/remote-cli/gitpod-code --openExternal"