Skip to content

Commit 5f8da64

Browse files
Andrea Falzettifelladrinakosyakov
committed
feat: change jetbrains ides dir layout
Co-authored-by: Victor Nogueira <[email protected]> Co-authored-by: Anton Kosyakov <[email protected]>
1 parent b05ba0d commit 5f8da64

22 files changed

+316
-108
lines changed

components/ide/jetbrains/backend-plugin/leeway.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ FROM scratch
1111
ARG JETBRAINS_BACKEND_QUALIFIER
1212
# ensures right permissions for /ide-desktop-plugins
1313
COPY --from=base_builder --chown=33333:33333 /ide-desktop-plugins/ /ide-desktop-plugins/
14-
COPY --chown=33333:33333 components-ide-jetbrains-backend-plugin--plugin-${JETBRAINS_BACKEND_QUALIFIER}/build/gitpod-remote /ide-desktop-plugins/gitpod-remote/
14+
COPY --chown=33333:33333 components-ide-jetbrains-backend-plugin--plugin-${JETBRAINS_BACKEND_QUALIFIER}/build/gitpod-remote /ide-desktop-plugins/gitpod-remote-${JETBRAINS_BACKEND_QUALIFIER}/

components/ide/jetbrains/cli/cmd/root.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ func Execute() {
2727

2828
func getCliApiUrl() *url.URL {
2929
var backendPort = 63342
30+
// TODO look up under alias + qualifier, i.e. intellij or intellij-latest
3031
if _, fileStatError := os.Stat("/ide-desktop/bin/idea-cli-dev"); !errors.Is(fileStatError, os.ErrNotExist) {
3132
backendPort = backendPort + 1
3233
}

components/ide/jetbrains/image/BUILD.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ const generateIDEBuildPackage = function (ideConfig, qualifier) {
5454
let pkg = {
5555
name,
5656
type: "docker",
57-
srcs: ["startup.sh", `supervisor-ide-config_${ideConfig.name}.json`],
57+
srcs: ["startup.sh", `supervisor-ide-config_${name}.json`],
5858
deps: ["components/ide/jetbrains/image/status:app", `:download-${name}`, "components/ide/jetbrains/cli:app"],
5959
config: {
6060
dockerfile: "leeway.Dockerfile",
@@ -63,7 +63,7 @@ const generateIDEBuildPackage = function (ideConfig, qualifier) {
6363
},
6464
buildArgs: {
6565
JETBRAINS_DOWNLOAD_QUALIFIER: name,
66-
SUPERVISOR_IDE_CONFIG: `supervisor-ide-config_${ideConfig.name}.json`,
66+
SUPERVISOR_IDE_CONFIG: `supervisor-ide-config_${name}.json`,
6767
JETBRAINS_BACKEND_QUALIFIER: qualifier,
6868
JETBRAINS_BACKEND_VERSION: getIDEVersion(qualifier, args[`${ideConfig.name}DownloadUrl`]),
6969
},
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// Copyright (c) 2022 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+
5+
// @ts-check
6+
const fs = require("fs");
7+
8+
const ideConfigs = [
9+
{
10+
name: "intellij",
11+
displayName: "IntelliJ IDEA",
12+
},
13+
{
14+
name: "goland",
15+
displayName: "GoLand",
16+
},
17+
{
18+
name: "pycharm",
19+
displayName: "PyCharm",
20+
},
21+
{
22+
name: "phpstorm",
23+
displayName: "PhpStorm",
24+
},
25+
{
26+
name: "rubymine",
27+
displayName: "RubyMine",
28+
},
29+
{
30+
name: "webstorm",
31+
displayName: "WebStorm",
32+
},
33+
{
34+
name: "rider",
35+
displayName: "Rider",
36+
},
37+
{
38+
name: "clion",
39+
displayName: "CLion",
40+
},
41+
];
42+
43+
["stable", "latest"].forEach((qualifier) => {
44+
ideConfigs.forEach((ideConfig) => {
45+
const name = ideConfig.name + (qualifier === "stable" ? "" : "-" + qualifier);
46+
const template = {
47+
entrypoint: `/ide-desktop/${name}/status`,
48+
entrypointArgs: ["{DESKTOPIDEPORT}", ideConfig.name, `Open in ${ideConfig.displayName}`],
49+
readinessProbe: {
50+
type: "http",
51+
http: {
52+
path: "/status",
53+
},
54+
},
55+
};
56+
fs.writeFileSync(`supervisor-ide-config_${name}.json`, JSON.stringify(template, null, 2), "utf-8");
57+
});
58+
});

components/ide/jetbrains/image/leeway.Dockerfile

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,21 @@ ARG SUPERVISOR_IDE_CONFIG
1515
# ensures right permissions for /ide-desktop
1616
COPY --from=base_builder --chown=33333:33333 /ide-desktop/ /ide-desktop/
1717
COPY --chown=33333:33333 ${SUPERVISOR_IDE_CONFIG} /ide-desktop/supervisor-ide-config.json
18-
COPY --chown=33333:33333 components-ide-jetbrains-image--download-${JETBRAINS_DOWNLOAD_QUALIFIER}/backend /ide-desktop/backend
19-
COPY --chown=33333:33333 components-ide-jetbrains-image-status--app/status /ide-desktop
18+
COPY --chown=33333:33333 components-ide-jetbrains-image--download-${JETBRAINS_DOWNLOAD_QUALIFIER}/backend /ide-desktop/${JETBRAINS_DOWNLOAD_QUALIFIER}/backend
19+
COPY --chown=33333:33333 components-ide-jetbrains-image-status--app/status /ide-desktop/${JETBRAINS_DOWNLOAD_QUALIFIER}
2020

2121
ARG JETBRAINS_BACKEND_QUALIFIER
2222
ENV GITPOD_ENV_SET_JETBRAINS_BACKEND_QUALIFIER ${JETBRAINS_BACKEND_QUALIFIER}
2323

24-
COPY --chown=33333:33333 components-ide-jetbrains-cli--app/cli /ide-desktop/bin/idea-cli
25-
ENV GITPOD_ENV_APPEND_PATH /ide-desktop/bin:
24+
COPY --chown=33333:33333 components-ide-jetbrains-cli--app/cli /ide-desktop/${JETBRAINS_DOWNLOAD_QUALIFIER}/bin/idea-cli
25+
ENV GITPOD_ENV_APPEND_PATH /ide-desktop/${JETBRAINS_DOWNLOAD_QUALIFIER}/bin:
2626

2727
# editor config
28-
ENV GITPOD_ENV_SET_EDITOR "/ide-desktop/bin/idea-cli open"
28+
ENV GITPOD_ENV_SET_EDITOR "/ide-desktop/${JETBRAINS_DOWNLOAD_QUALIFIER}/bin/idea-cli open"
2929
ENV GITPOD_ENV_SET_VISUAL "$GITPOD_ENV_SET_EDITOR"
3030
ENV GITPOD_ENV_SET_GP_OPEN_EDITOR "$GITPOD_ENV_SET_EDITOR"
3131
ENV GITPOD_ENV_SET_GIT_EDITOR "$GITPOD_ENV_SET_EDITOR --wait"
32-
ENV GITPOD_ENV_SET_GP_PREVIEW_BROWSER "/ide-desktop/bin/idea-cli preview"
33-
ENV GITPOD_ENV_SET_GP_EXTERNAL_BROWSER "/ide-desktop/bin/idea-cli preview"
32+
ENV GITPOD_ENV_SET_GP_PREVIEW_BROWSER "/ide-desktop/${JETBRAINS_DOWNLOAD_QUALIFIER}/bin/idea-cli preview"
33+
ENV GITPOD_ENV_SET_GP_EXTERNAL_BROWSER "/ide-desktop/${JETBRAINS_DOWNLOAD_QUALIFIER}/bin/idea-cli preview"
3434

3535
LABEL "io.gitpod.ide.version"=$JETBRAINS_BACKEND_VERSION

components/ide/jetbrains/image/status/main.go

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,16 @@ var (
4747
Version = ""
4848
)
4949

50-
const BackendPath = "/ide-desktop/backend"
51-
const ProductInfoPath = BackendPath + "/product-info.json"
52-
5350
type LaunchContext struct {
5451
startTime time.Time
5552

5653
port string
5754
alias string
5855
label string
5956

57+
qualifier string
58+
productDir string
59+
backendDir string
6060
info *ProductInfo
6161
backendVersion *version.Version
6262
wsInfo *supervisor.WorkspaceInfoResponse
@@ -99,7 +99,16 @@ func main() {
9999
label = os.Args[3]
100100
}
101101

102-
info, err := resolveProductInfo()
102+
qualifier := os.Getenv("JETBRAINS_BACKEND_QUALIFIER")
103+
if qualifier == "stable" {
104+
qualifier = ""
105+
} else {
106+
qualifier = "-" + qualifier
107+
}
108+
productDir := "/ide-desktop/" + alias + qualifier
109+
backendDir := productDir + "/backend"
110+
111+
info, err := resolveProductInfo(backendDir)
103112
if err != nil {
104113
log.WithError(err).Error("failed to resolve product info")
105114
return
@@ -124,6 +133,9 @@ func main() {
124133
alias: alias,
125134
label: label,
126135

136+
qualifier: qualifier,
137+
productDir: productDir,
138+
backendDir: backendDir,
127139
info: info,
128140
backendVersion: backendVersion,
129141
wsInfo: wsInfo,
@@ -359,19 +371,12 @@ func launch(launchCtx *LaunchContext) {
359371
idePrefix = "idea"
360372
}
361373
// [idea64|goland64|pycharm64|phpstorm64].vmoptions
362-
launchCtx.vmOptionsFile = fmt.Sprintf("/ide-desktop/backend/bin/%s64.vmoptions", idePrefix)
374+
launchCtx.vmOptionsFile = fmt.Sprintf(launchCtx.backendDir+"/bin/%s64.vmoptions", idePrefix)
363375
err = configureVMOptions(gitpodConfig, launchCtx.alias, launchCtx.vmOptionsFile)
364376
if err != nil {
365377
log.WithError(err).Error("failed to configure vmoptions")
366378
}
367379

368-
qualifier := os.Getenv("JETBRAINS_BACKEND_QUALIFIER")
369-
if qualifier == "stable" {
370-
qualifier = ""
371-
} else {
372-
qualifier = "-" + qualifier
373-
}
374-
375380
var riderSolutionFile string
376381
if launchCtx.alias == "rider" {
377382
riderSolutionFile, err = findRiderSolutionFile(projectDir)
@@ -380,10 +385,10 @@ func launch(launchCtx *LaunchContext) {
380385
}
381386
}
382387

383-
configDir := fmt.Sprintf("/workspace/.config/JetBrains%s", qualifier)
388+
configDir := fmt.Sprintf("/workspace/.config/JetBrains%s", launchCtx.qualifier)
384389
launchCtx.projectDir = projectDir
385390
launchCtx.configDir = configDir
386-
launchCtx.systemDir = fmt.Sprintf("/workspace/.cache/JetBrains%s", qualifier)
391+
launchCtx.systemDir = fmt.Sprintf("/workspace/.cache/JetBrains%s", launchCtx.qualifier)
387392
launchCtx.riderSolutionFile = riderSolutionFile
388393
launchCtx.projectContextDir = resolveProjectContextDir(launchCtx)
389394
launchCtx.projectConfigDir = fmt.Sprintf("%s/RemoteDev-%s/%s", configDir, launchCtx.info.ProductCode, strings.ReplaceAll(launchCtx.projectContextDir, "/", "_"))
@@ -407,7 +412,7 @@ func launch(launchCtx *LaunchContext) {
407412
}
408413

409414
// install gitpod plugin
410-
err = linkRemotePlugin()
415+
err = linkRemotePlugin(launchCtx)
411416
if err != nil {
412417
log.WithError(err).Error("failed to install gitpod-remote plugin")
413418
}
@@ -445,7 +450,7 @@ func run(launchCtx *LaunchContext) {
445450
}
446451

447452
// resolveUserEnvs emulats the interactive login shell to ensure that all user defined shell scripts are loaded
448-
func resolveUserEnvs() (userEnvs []string, err error) {
453+
func resolveUserEnvs(launchCtx *LaunchContext) (userEnvs []string, err error) {
449454
shell := os.Getenv("SHELL")
450455
if shell == "" {
451456
shell = "/bin/bash"
@@ -454,7 +459,7 @@ func resolveUserEnvs() (userEnvs []string, err error) {
454459
if err != nil {
455460
return
456461
}
457-
envCmd := exec.Command(shell, []string{"-ilc", "/ide-desktop/status env " + mark.String()}...)
462+
envCmd := exec.Command(shell, []string{"-ilc", launchCtx.productDir + "/status env " + mark.String()}...)
458463
envCmd.Stderr = os.Stderr
459464
output, err := envCmd.Output()
460465
if err != nil {
@@ -469,7 +474,7 @@ func resolveUserEnvs() (userEnvs []string, err error) {
469474

470475
func remoteDevServerCmd(args []string, launchCtx *LaunchContext) *exec.Cmd {
471476
if launchCtx.env == nil {
472-
userEnvs, err := resolveUserEnvs()
477+
userEnvs, err := resolveUserEnvs(launchCtx)
473478
if err == nil {
474479
launchCtx.env = append(launchCtx.env, userEnvs...)
475480
} else {
@@ -484,15 +489,15 @@ func remoteDevServerCmd(args []string, launchCtx *LaunchContext) *exec.Cmd {
484489
fmt.Sprintf("IJ_HOST_SYSTEM_BASE_DIR=%s", launchCtx.systemDir),
485490
)
486491

487-
// instead put them into /ide-desktop/backend/bin/idea64.vmoptions
492+
// instead put them into /ide-desktop/${alias}${qualifier}/backend/bin/idea64.vmoptions
488493
// otherwise JB will complain to a user on each startup
489-
// by default remote dev already set -Xmx2048m, see /ide-desktop/backend/plugins/remote-dev-server/bin/launcher.sh
494+
// by default remote dev already set -Xmx2048m, see /ide-desktop/${alias}${qualifier}/backend/plugins/remote-dev-server/bin/launcher.sh
490495
launchCtx.env = append(launchCtx.env, "JAVA_TOOL_OPTIONS=")
491496

492497
log.WithField("env", launchCtx.env).Debug("resolved launch env")
493498
}
494499

495-
cmd := exec.Command(BackendPath+"/bin/remote-dev-server.sh", args...)
500+
cmd := exec.Command(launchCtx.backendDir+"/bin/remote-dev-server.sh", args...)
496501
cmd.Env = launchCtx.env
497502
cmd.Stderr = os.Stderr
498503
cmd.Stdout = os.Stdout
@@ -619,8 +624,8 @@ type ProductInfo struct {
619624
ProductCode string `json:"productCode"`
620625
}
621626

622-
func resolveProductInfo() (*ProductInfo, error) {
623-
f, err := os.Open(ProductInfoPath)
627+
func resolveProductInfo(backendDir string) (*ProductInfo, error) {
628+
f, err := os.Open(backendDir + "/product-info.json")
624629
if err != nil {
625630
return nil, err
626631
}
@@ -764,13 +769,13 @@ func getProductConfig(config *gitpod.GitpodConfig, alias string) *gitpod.Jetbrai
764769
return productConfig
765770
}
766771

767-
func linkRemotePlugin() error {
768-
remotePluginDir := BackendPath + "/plugins/gitpod-remote"
772+
func linkRemotePlugin(launchCtx *LaunchContext) error {
773+
remotePluginDir := launchCtx.backendDir + "/plugins/gitpod-remote"
769774
_, err := os.Stat(remotePluginDir)
770775
if err == nil || !errors.Is(err, os.ErrNotExist) {
771776
return nil
772777
}
773-
return os.Symlink("/ide-desktop-plugins/gitpod-remote", remotePluginDir)
778+
return os.Symlink("/ide-desktop-plugins/gitpod-remote-"+os.Getenv("JETBRAINS_BACKEND_QUALIFIER"), remotePluginDir)
774779
}
775780

776781
// TODO(andreafalzetti): remove dir scanning once this is implemented https://youtrack.jetbrains.com/issue/GTW-2402/Rider-Open-Project-dialog-not-displaying-in-remote-dev
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"entrypoint": "/ide-desktop/clion-latest/status",
3+
"entrypointArgs": [
4+
"{DESKTOPIDEPORT}",
5+
"clion",
6+
"Open in CLion"
7+
],
8+
"readinessProbe": {
9+
"type": "http",
10+
"http": {
11+
"path": "/status"
12+
}
13+
}
14+
}
Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
{
2-
"entrypoint": "/ide-desktop/status",
3-
"entrypointArgs": [ "{DESKTOPIDEPORT}", "clion", "Open in CLion" ],
4-
"readinessProbe": {
5-
"type": "http",
6-
"http": {
7-
"path": "/status"
8-
}
9-
}
10-
}
2+
"entrypoint": "/ide-desktop/clion/status",
3+
"entrypointArgs": [
4+
"{DESKTOPIDEPORT}",
5+
"clion",
6+
"Open in CLion"
7+
],
8+
"readinessProbe": {
9+
"type": "http",
10+
"http": {
11+
"path": "/status"
12+
}
13+
}
14+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"entrypoint": "/ide-desktop/goland-latest/status",
3+
"entrypointArgs": [
4+
"{DESKTOPIDEPORT}",
5+
"goland",
6+
"Open in GoLand"
7+
],
8+
"readinessProbe": {
9+
"type": "http",
10+
"http": {
11+
"path": "/status"
12+
}
13+
}
14+
}
Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
{
2-
"entrypoint": "/ide-desktop/status",
3-
"entrypointArgs": [ "{DESKTOPIDEPORT}", "goland", "Open in GoLand" ],
4-
"readinessProbe": {
5-
"type": "http",
6-
"http": {
7-
"path": "/status"
8-
}
9-
}
10-
}
2+
"entrypoint": "/ide-desktop/goland/status",
3+
"entrypointArgs": [
4+
"{DESKTOPIDEPORT}",
5+
"goland",
6+
"Open in GoLand"
7+
],
8+
"readinessProbe": {
9+
"type": "http",
10+
"http": {
11+
"path": "/status"
12+
}
13+
}
14+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"entrypoint": "/ide-desktop/intellij-latest/status",
3+
"entrypointArgs": [
4+
"{DESKTOPIDEPORT}",
5+
"intellij",
6+
"Open in IntelliJ IDEA"
7+
],
8+
"readinessProbe": {
9+
"type": "http",
10+
"http": {
11+
"path": "/status"
12+
}
13+
}
14+
}

0 commit comments

Comments
 (0)