Skip to content

Commit

Permalink
[jb] extract backend plugin to own image
Browse files Browse the repository at this point in the history
  • Loading branch information
akosyakov committed Aug 25, 2022
1 parent 5a8e27b commit 8c87eac
Show file tree
Hide file tree
Showing 33 changed files with 724 additions and 441 deletions.
2 changes: 2 additions & 0 deletions components/BUILD.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ packages:
- components/ide/code-desktop:docker
- components/ide/code-desktop:docker-insiders
- components/ide/code:docker
- components/ide/jetbrains/backend-plugin:stable
- components/ide/jetbrains/backend-plugin:latest
- components/ide/jetbrains/image:goland
- components/ide/jetbrains/image:goland-latest
- components/ide/jetbrains/image:intellij
Expand Down
10 changes: 10 additions & 0 deletions components/gitpod-protocol/src/ide-protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,14 @@ export interface IDEOption {
* we resolve the tag regularly to the most recent image version.
*/
resolveImageDigest?: boolean;

/**
* The plugin image ref for the IDE image, this image ref always resolve to digest.
*/
pluginImage?: string;

/**
* The latest plugin image ref for the latest IDE image, this image ref always resolve to digest.
*/
pluginLatestImage?: string;
}
3 changes: 3 additions & 0 deletions components/gitpod-protocol/src/workspace-instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,9 @@ export interface WorkspaceInstanceConfiguration {
// desktopIdeImage is the ref of the desktop IDE image this instance uses.
desktopIdeImage?: string;

// desktopIdePluginImage is the ref of the desktop IDE plugin image this instance uses.
desktopIdePluginImage?: string;

// supervisorImage is the ref of the supervisor image this instance uses.
supervisorImage?: string;

Expand Down
36 changes: 36 additions & 0 deletions components/ide/jetbrains/backend-plugin/BUILD.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,40 @@
packages:
- name: docker
type: generic
argdeps:
- version
deps:
- :stable
- :latest
- name: stable
type: docker
deps:
- :plugin-stable
argdeps:
- imageRepoBase
config:
dockerfile: leeway.Dockerfile
metadata:
helm-component: workspace.desktopIdeImages.jbBackendPlugin
buildArgs:
JETBRAINS_BACKEND_QUALIFIER: stable
image:
- ${imageRepoBase}/ide/jb-backend-plugin:commit-${__git_commit}
- name: latest
type: docker
deps:
- :plugin-latest
argdeps:
- imageRepoBase
config:
dockerfile: leeway.Dockerfile
metadata:
helm-component: workspace.desktopIdeImages.jbBackendPluginLatest
buildArgs:
JETBRAINS_BACKEND_QUALIFIER: latest
image:
- ${imageRepoBase}/ide/jb-backend-plugin:${version}
- ${imageRepoBase}/ide/jb-backend-plugin:commit-${__git_commit}-latest
- name: plugin-stable
type: generic
deps:
Expand Down
9 changes: 9 additions & 0 deletions components/ide/jetbrains/backend-plugin/leeway.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# 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.

# for debugging
# FROM alpine:3.16
FROM scratch
ARG JETBRAINS_BACKEND_QUALIFIER
COPY --chown=33333:33333 components-ide-jetbrains-backend-plugin--plugin-${JETBRAINS_BACKEND_QUALIFIER}/build/gitpod-remote /ide-desktop/backend/plugins/gitpod-remote
8 changes: 0 additions & 8 deletions components/ide/jetbrains/image/BUILD.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ packages:
- "startup.sh"
- "supervisor-ide-config_intellij.json"
deps:
- components/ide/jetbrains/backend-plugin:plugin-stable
- components/ide/jetbrains/image/status:app
- components/ide/jetbrains/image/download:intellij
- components/ide/jetbrains/cli:app
Expand All @@ -40,7 +39,6 @@ packages:
- "startup.sh"
- "supervisor-ide-config_intellij.json"
deps:
- components/ide/jetbrains/backend-plugin:plugin-latest
- components/ide/jetbrains/image/status:app
- components/ide/jetbrains/image/download:intellij-latest
- components/ide/jetbrains/cli:app
Expand All @@ -63,7 +61,6 @@ packages:
- "startup.sh"
- "supervisor-ide-config_goland.json"
deps:
- components/ide/jetbrains/backend-plugin:plugin-stable
- components/ide/jetbrains/image/status:app
- components/ide/jetbrains/image/download:goland
- components/ide/jetbrains/cli:app
Expand All @@ -85,7 +82,6 @@ packages:
- "startup.sh"
- "supervisor-ide-config_goland.json"
deps:
- components/ide/jetbrains/backend-plugin:plugin-latest
- components/ide/jetbrains/image/status:app
- components/ide/jetbrains/image/download:goland-latest
- components/ide/jetbrains/cli:app
Expand All @@ -108,7 +104,6 @@ packages:
- "startup.sh"
- "supervisor-ide-config_pycharm.json"
deps:
- components/ide/jetbrains/backend-plugin:plugin-stable
- components/ide/jetbrains/image/status:app
- components/ide/jetbrains/image/download:pycharm
- components/ide/jetbrains/cli:app
Expand All @@ -130,7 +125,6 @@ packages:
- "startup.sh"
- "supervisor-ide-config_pycharm.json"
deps:
- components/ide/jetbrains/backend-plugin:plugin-latest
- components/ide/jetbrains/image/status:app
- components/ide/jetbrains/image/download:pycharm-latest
- components/ide/jetbrains/cli:app
Expand All @@ -153,7 +147,6 @@ packages:
- "startup.sh"
- "supervisor-ide-config_phpstorm.json"
deps:
- components/ide/jetbrains/backend-plugin:plugin-stable
- components/ide/jetbrains/image/status:app
- components/ide/jetbrains/image/download:phpstorm
- components/ide/jetbrains/cli:app
Expand All @@ -175,7 +168,6 @@ packages:
- "startup.sh"
- "supervisor-ide-config_phpstorm.json"
deps:
- components/ide/jetbrains/backend-plugin:plugin-latest
- components/ide/jetbrains/image/status:app
- components/ide/jetbrains/image/download:phpstorm-latest
- components/ide/jetbrains/cli:app
Expand Down
1 change: 0 additions & 1 deletion components/ide/jetbrains/image/leeway.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ 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 components-ide-jetbrains-image-download--${JETBRAINS_DOWNLOAD_QUALIFIER}/backend /ide-desktop/backend
COPY --chown=33333:33333 components-ide-jetbrains-backend-plugin--plugin-${JETBRAINS_BACKEND_QUALIFIER}/build/gitpod-remote /ide-desktop/backend/plugins/gitpod-remote
COPY --chown=33333:33333 components-ide-jetbrains-image-status--app/status /ide-desktop

ARG JETBRAINS_BACKEND_QUALIFIER
Expand Down
76 changes: 45 additions & 31 deletions components/registry-facade-api/go/imagespec.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion components/registry-facade-api/go/provider.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion components/registry-facade-api/go/provider_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion components/registry-facade-api/imagespec.proto
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ message ImageSpec {
string desktop_ide_ref = 4;
// supervisor_ref points to an image denotign the supervisor to use
string supervisor_ref = 5;
// desktop_ide_plugin_ref points to an image denotign the desktop IDE plugin to use
string desktop_ide_plugin_ref = 6;
}

// ContentLayer is a layer that provides a workspace's content
Expand Down Expand Up @@ -51,4 +53,4 @@ message RemoteContentLayer {
message DirectContentLayer {
// the bytes of the uncompressed tar file which is served as layer
bytes content = 1;
}
}
10 changes: 10 additions & 0 deletions components/registry-facade/pkg/registry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,16 @@ func NewRegistry(cfg config.Config, newResolver ResolverProvider, reg prometheus
}
layerSources = append(layerSources, desktopIdeLayerSource)

// desktop IDE plugin layer
desktopIdePluginRefSource := func(s *api.ImageSpec) (ref string, err error) {
return s.GetDesktopIdePluginRef(), nil
}
desktopIdePluginLayerSource, err := NewSpecMappedImageSource(newResolver, desktopIdePluginRefSource)
if err != nil {
return nil, err
}
layerSources = append(layerSources, desktopIdePluginLayerSource)

// supervisor layer
supervisorRefSource := func(s *api.ImageSpec) (ref string, err error) {
return s.SupervisorRef, nil
Expand Down
10 changes: 9 additions & 1 deletion components/server/src/workspace/workspace-starter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,16 @@ export const chooseIDE = (
) => {
const defaultIDEOption = ideOptions.options[ideOptions.defaultIde];
const defaultIdeImage = useLatest ? defaultIDEOption.latestImage ?? defaultIDEOption.image : defaultIDEOption.image;
const data: { desktopIdeImage?: string; ideImage: string } = {
const data: { desktopIdeImage?: string; desktopIdePluginImage?: string; ideImage: string } = {
ideImage: defaultIdeImage,
};
const chooseOption = ideOptions.options[ideChoice] ?? defaultIDEOption;
const isDesktopIde = chooseOption.type === "desktop";
if (isDesktopIde) {
data.desktopIdeImage = useLatest ? chooseOption?.latestImage ?? chooseOption?.image : chooseOption?.image;
data.desktopIdePluginImage = useLatest
? chooseOption?.pluginLatestImage ?? chooseOption?.pluginImage
: chooseOption?.pluginImage;
if (hasIdeSettingPerm) {
data.desktopIdeImage = data.desktopIdeImage || ideChoice;
}
Expand Down Expand Up @@ -783,13 +786,17 @@ export class WorkspaceStarter {
);
configuration.ideImage = choose.ideImage;
configuration.desktopIdeImage = choose.desktopIdeImage;
configuration.desktopIdePluginImage = choose.desktopIdePluginImage;
}

const referrerIde = this.resolveReferrerIDE(workspace, user, ideConfig);
if (referrerIde) {
configuration.desktopIdeImage = useLatest
? referrerIde.option.latestImage ?? referrerIde.option.image
: referrerIde.option.image;
configuration.desktopIdePluginImage = useLatest
? referrerIde.option.pluginLatestImage ?? referrerIde.option.pluginImage
: referrerIde.option.pluginImage;
if (!user.additionalData?.ideSettings) {
// A user does not have IDE settings configured yet configure it with a referrer ide as default.
const additionalData = user?.additionalData || {};
Expand Down Expand Up @@ -1496,6 +1503,7 @@ export class WorkspaceStarter {
const startWorkspaceSpecIDEImage = new IDEImage();
startWorkspaceSpecIDEImage.setWebRef(ideImage);
startWorkspaceSpecIDEImage.setDesktopRef(instance.configuration?.desktopIdeImage || "");
startWorkspaceSpecIDEImage.setDesktopPluginRef(instance.configuration?.desktopIdePluginImage || "");
startWorkspaceSpecIDEImage.setSupervisorRef(instance.configuration?.supervisorImage || "");
spec.setIdeImage(startWorkspaceSpecIDEImage);
spec.setDeprecatedIdeImage(ideImage);
Expand Down
2 changes: 2 additions & 0 deletions components/ws-manager-api/core.proto
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,8 @@ message IDEImage {
string desktop_ref = 2;
// supervisor_ref is a reference to an OCI image used as supervisor
string supervisor_ref = 3;
// desktop_plugin_ref is an optional reference to an OCI image used for serving desktop IDE plugin
string desktop_plugin_ref = 4;
}

// WorkspaceSpec is the specification of a workspace at runtime
Expand Down
Loading

0 comments on commit 8c87eac

Please sign in to comment.