Skip to content

Commit

Permalink
[ide] Add JetBrains IDE images
Browse files Browse the repository at this point in the history
  • Loading branch information
corneliusludmann committed Oct 25, 2021
1 parent 1d7c6ca commit 74d451c
Show file tree
Hide file tree
Showing 14 changed files with 229 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .werft/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ export async function build(context, version) {
if (withContrib || publishRelease) {
exec(`leeway build --docker-build-options network=host --werft=true -c remote ${dontTest ? '--dont-test' : ''} -Dversion=${version} -DimageRepoBase=${imageRepo} contrib:all`);
}
exec(`leeway build --docker-build-options network=host --werft=true -c remote ${retag} --coverage-output-path=${coverageOutput} -Dversion=${version} -DremoveSources=false -DimageRepoBase=${imageRepo} -DlocalAppVersion=${localAppVersion} -DnpmPublishTrigger=${publishToNpm ? Date.now() : 'false'}`);
const jetbrainsArgs = `-DINTELLIJ_PLUGIN_PLATFORM_VERSION=${process.env.INTELLIJ_PLUGIN_PLATFORM_VERSION} -DINTELLIJ_BACKEND_URL=${process.env.INTELLIJ_BACKEND_URL} -DGOLAND_BACKEND_URL=${process.env.GOLAND_BACKEND_URL}`;
exec(`leeway build --docker-build-options network=host --werft=true -c remote ${retag} --coverage-output-path=${coverageOutput} -Dversion=${version} -DremoveSources=false -DimageRepoBase=${imageRepo} -DlocalAppVersion=${localAppVersion} ${jetbrainsArgs} -DnpmPublishTrigger=${publishToNpm ? Date.now() : 'false'}`);
if (publishRelease) {
try {
werft.phase("publish", "checking version semver compliance...");
Expand Down
3 changes: 3 additions & 0 deletions .werft/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ pod:
secretKeyRef:
name: codecov
key: token
envFrom:
- secretRef:
name: jetbrains-secrets
command:
- bash
- -c
Expand Down
17 changes: 16 additions & 1 deletion chart/templates/server-ide-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,20 @@
{{ template "gitpod.comp.imageRepo" . }}:{{- $comp.insidersVersion | default (include "gitpod.comp.version" .) -}}
{{- end -}}

{{- define "ide-images-aliases"}}
{{- $ := .root -}}
{{- $gp := .gp -}}
code: {{ (include "stable-image-full" (dict "root" $ "gp" $gp "comp" $gp.components.workspace.codeImage)) }}
code-latest: {{ (include "insider-image-full" (dict "root" $ "gp" $gp "comp" $gp.components.workspace.codeImage)) }}
{{ end }}

{{- define "desktop-ide-images-aliases"}}
{{- $ := .root -}}
{{- $gp := .gp -}}
intellij: {{ (include "gitpod.comp.imageFull" (dict "root" $ "gp" $gp "comp" $gp.components.workspace.desktopIdeImages.intellij)) }}
goland: {{ (include "gitpod.comp.imageFull" (dict "root" $ "gp" $gp "comp" $gp.components.workspace.desktopIdeImages.goland)) }}
{{ end }}

{{- if $comp.serverIdeConfigDeploy.enabled }}
apiVersion: v1
kind: ConfigMap
Expand All @@ -33,6 +47,7 @@ data:
{
"ideVersion": "{{ .Values.components.workspace.codeImage.stableVersion }}",
"ideImageRepo": "{{ template "gitpod.comp.imageRepo" (dict "root" . "gp" $.Values "comp" .Values.components.workspace.codeImage) }}",
"ideImageAliases": {{ (dict "code-latest" (include "insider-image-full" (dict "root" . "gp" $.Values "comp" .Values.components.workspace.codeImage)) "code" (include "stable-image-full" (dict "root" . "gp" $.Values "comp" .Values.components.workspace.codeImage))) | toJson }}
"ideImageAliases": {{ (include "ide-images-aliases" (dict "root" . "gp" $.Values)) | fromYaml | toJson }},
"desktopIdeImageAliases": {{ (include "desktop-ide-images-aliases" (dict "root" . "gp" $.Values)) | fromYaml | toJson }}
}
{{- end }}
5 changes: 5 additions & 0 deletions chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,11 @@ components:
imageName: "ide/code"
stableVersion: "commit-7107fb8bde0b1f92265402ad5fa09a51022b14dd"
insidersVersion: "nightly"
desktopIdeImages:
intellij:
imageName: "ide/intellij"
goland:
imageName: "ide/goland"
supervisor:
imageName: "supervisor"
dockerUp:
Expand Down
3 changes: 2 additions & 1 deletion components/BUILD.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ packages:
- dev:all-app
- installer:app
- components/gitpod-protocol:all
- components/ide/jetbrains/backend-plugin:plugin
- operations/observability/mixins:lint
- name: docker-versions
type: docker
Expand All @@ -41,6 +40,8 @@ packages:
- components/ee/ws-scheduler:docker
- components/gitpod-db:docker
- components/ide/code:docker
- components/ide/jetbrains/image:intellij
- components/ide/jetbrains/image:goland
- components/ide/theia:docker
- components/image-builder:docker
- components/image-builder-mk3:docker
Expand Down
2 changes: 1 addition & 1 deletion components/ide/jetbrains/backend-plugin/.project
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</natures>
<filteredResources>
<filter>
<id>1634286379907</id>
<id>0</id>
<name></name>
<type>30</type>
<matcher>
Expand Down
3 changes: 3 additions & 0 deletions components/ide/jetbrains/backend-plugin/BUILD.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ packages:
- "gradle/wrapper/*"
- "gradlew"
- "settings.gradle.kts"
argdeps:
- INTELLIJ_PLUGIN_PLATFORM_VERSION
env:
- JAVA_HOME=/home/gitpod/.sdkman/candidates/java/current
- INTELLIJ_PLUGIN_PLATFORM_VERSION=${INTELLIJ_PLUGIN_PLATFORM_VERSION}
config:
commands:
- ["./gradlew", "-PsupervisorApiProjectPath=components-supervisor-api-java--lib/", "-PgitpodProtocolProjectPath=components-gitpod-protocol-java--lib/", "buildPlugin"]
52 changes: 52 additions & 0 deletions components/ide/jetbrains/image/BUILD.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
packages:
- name: docker
type: generic
argdeps:
- version
deps:
- :intellij
- :goland
- name: intellij
type: docker
srcs:
- "startup.sh"
- "supervisor-ide-config_intellij.json"
- "status/go.mod"
- "status/main.go"
deps:
- components/ide/jetbrains/backend-plugin:plugin
argdeps:
- imageRepoBase
- INTELLIJ_BACKEND_URL
config:
dockerfile: leeway.Dockerfile
metadata:
helm-component: workspace.desktopIdeImages.intellij
buildArgs:
JETBRAINS_BACKEND_URL: ${INTELLIJ_BACKEND_URL}
SUPERVISOR_IDE_CONFIG: supervisor-ide-config_intellij.json
image:
- ${imageRepoBase}/ide/intellij:${version}
- ${imageRepoBase}/ide/intellij:commit-${__git_commit}
- name: goland
type: docker
srcs:
- "startup.sh"
- "supervisor-ide-config_goland.json"
- "status/go.mod"
- "status/main.go"
deps:
- components/ide/jetbrains/backend-plugin:plugin
argdeps:
- imageRepoBase
- GOLAND_BACKEND_URL
config:
dockerfile: leeway.Dockerfile
metadata:
helm-component: workspace.desktopIdeImages.goland
buildArgs:
JETBRAINS_BACKEND_URL: ${GOLAND_BACKEND_URL}
SUPERVISOR_IDE_CONFIG: supervisor-ide-config_goland.json
image:
- ${imageRepoBase}/ide/goland:${version}
- ${imageRepoBase}/ide/goland:commit-${__git_commit}
23 changes: 23 additions & 0 deletions components/ide/jetbrains/image/leeway.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright (c) 2021 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 golang:1.17 AS build
WORKDIR /app
COPY status/* /app/
RUN go build -o status

FROM alpine:3.14 as download
ARG JETBRAINS_BACKEND_URL
WORKDIR /workdir
RUN apk add --no-cache --upgrade curl gzip tar unzip
RUN curl -sSLo backend.tar.gz "$JETBRAINS_BACKEND_URL" && tar -xf backend.tar.gz --strip-components=1 && rm backend.tar.gz
COPY --chown=33333:33333 components-ide-jetbrains-backend-plugin--plugin/build/distributions/jetbrains-backend-plugin-1.0-SNAPSHOT.zip /workdir
RUN unzip jetbrains-backend-plugin-1.0-SNAPSHOT.zip -d plugins/ && rm jetbrains-backend-plugin-1.0-SNAPSHOT.zip

FROM scratch
ARG SUPERVISOR_IDE_CONFIG
COPY --chown=33333:33333 ${SUPERVISOR_IDE_CONFIG} /ide-desktop/supervisor-ide-config.json
COPY --chown=33333:33333 startup.sh /ide-desktop/
COPY --chown=33333:33333 --from=build /app/status /ide-desktop/
COPY --chown=33333:33333 --from=download /workdir/ /ide-desktop/backend/
16 changes: 16 additions & 0 deletions components/ide/jetbrains/image/startup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash -li
# Copyright (c) 2021 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.

set -euo pipefail

# kill background jobs when the script exits
trap "jobs -p | xargs -r kill" SIGINT SIGTERM EXIT

/ide-desktop/status 24000 "$1" &

export CWM_NON_INTERACTIVE=1
export CWM_HOST_PASSWORD=gitpod
export CWM_HOST_STATUS_OVER_HTTP_TOKEN=gitpod
/ide-desktop/backend/bin/remote-dev-server.sh cwmHost "$GITPOD_REPO_ROOT"
3 changes: 3 additions & 0 deletions components/ide/jetbrains/image/status/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/gitpod-io/gitpod/jetbrains/status

go 1.17
81 changes: 81 additions & 0 deletions components/ide/jetbrains/image/status/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
// Copyright (c) 2021 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.

package main

import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
"os"
"time"
)

// proxy for the Code With Me status endpoints that transforms it into the supervisor status format.
func main() {
if len(os.Args) < 2 {
fmt.Printf("Usage: %s <port> [<link label>]\n", os.Args[0])
os.Exit(1)
}
port := os.Args[1]
label := "Open JetBrains IDE"
if len(os.Args) > 2 {
label = os.Args[2]
}

http.HandleFunc("/status", func(w http.ResponseWriter, r *http.Request) {
var (
url = "http://localhost:63342/codeWithMe/unattendedHostStatus?token=gitpod"
client = http.Client{Timeout: 1 * time.Second}
)
resp, err := client.Get(url)
if err != nil {
http.Error(w, err.Error(), http.StatusServiceUnavailable)
return
}
defer resp.Body.Close()

bodyBytes, err := ioutil.ReadAll(resp.Body)
if err != nil {
http.Error(w, err.Error(), http.StatusServiceUnavailable)
return
}

if resp.StatusCode != http.StatusOK {
// log.Printf("Desktop IDE status proxy: getting non-200 status - %d\n%s\n", resp.StatusCode, bodyBytes)
http.Error(w, string(bodyBytes), resp.StatusCode)
return
}

type Projects struct {
JoinLink string `json:"joinLink"`
}
type Response struct {
Projects []Projects `json:"projects"`
}
jsonResp := &Response{}
err = json.Unmarshal(bodyBytes, &jsonResp)

if err != nil {
http.Error(w, "Error parsing JSON body from IDE status probe.", http.StatusServiceUnavailable)
return
}
if len(jsonResp.Projects) != 1 {
http.Error(w, "projects size != 1", http.StatusServiceUnavailable)
return
}
response := make(map[string]string)
response["link"] = jsonResp.Projects[0].JoinLink
response["label"] = label
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(response)
})

fmt.Printf("Starting status proxy for desktop IDE at port %s\n", port)
if err := http.ListenAndServe(fmt.Sprintf(":%s", port), nil); err != nil {
log.Fatal(err)
}
}
11 changes: 11 additions & 0 deletions components/ide/jetbrains/image/supervisor-ide-config_goland.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"entrypoint": "/ide-desktop/startup.sh",
"entrypointArgs": [ "Open GoLand IDE" ],
"readinessProbe": {
"type": "http",
"http": {
"port": 24000,
"path": "/status"
}
}
}
11 changes: 11 additions & 0 deletions components/ide/jetbrains/image/supervisor-ide-config_intellij.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"entrypoint": "/ide-desktop/startup.sh",
"entrypointArgs": [ "Open IntelliJ IDEA IDE" ],
"readinessProbe": {
"type": "http",
"http": {
"port": 24000,
"path": "/status"
}
}
}

0 comments on commit 74d451c

Please sign in to comment.