Skip to content

Commit

Permalink
Add all JB IDEs with the remote development support
Browse files Browse the repository at this point in the history
Signed-off-by: Artem Zatsarynnyi <[email protected]>
  • Loading branch information
azatsarynnyy committed Sep 16, 2024
1 parent 4f93ad9 commit aadb4ca
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 22 deletions.
35 changes: 29 additions & 6 deletions build/dockerfiles/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,48 @@
# https://registry.access.redhat.com/ubi8/nodejs-20
FROM registry.access.redhat.com/ubi8/nodejs-20:1-50.1720405266

# Dockerfile for building a container that brings the Jet Brains IDEs with the remote developemnt support.
# On a workspace start, the requested IDE is copied to the shared volume which is mounted to a folder in a dev container.
WORKDIR /idea-dist/
RUN curl -sL https://download-cdn.jetbrains.com/idea/ideaIU-2024.2.tar.gz | tar xzf - --strip-components=1

WORKDIR /pycharm-dist/
RUN curl -sL https://download-cdn.jetbrains.com/python/pycharm-professional-2024.2.tar.gz | tar xzf - --strip-components=1

WORKDIR /goland-dist/
RUN curl -sL https://download-cdn.jetbrains.com/go/goland-2024.2.tar.gz | tar xzf - --strip-components=1

WORKDIR /webstorm-dist/
RUN curl -sL https://download-cdn.jetbrains.com/webstorm/WebStorm-2024.2.tar.gz | tar xzf - --strip-components=1

WORKDIR /clion-dist/
RUN curl -sL https://download-cdn.jetbrains.com/cpp/CLion-2024.2.tar.gz | tar xzf - --strip-components=1

WORKDIR /phpstorm-dist/
RUN curl -sL https://download-cdn.jetbrains.com/webide/PhpStorm-2024.2.tar.gz | tar xzf - --strip-components=1

WORKDIR /rubymine-dist/
RUN curl -sL https://download-cdn.jetbrains.com/ruby/RubyMine-2024.2.tar.gz | tar xzf - --strip-components=1

WORKDIR /rider-dist/
RUN curl -sL https://download-cdn.jetbrains.com/rider/JetBrains.Rider-2024.2.tar.gz | tar xzf - --strip-components=1

USER 0

COPY --chmod=755 /build/dockerfiles/*.sh /
COPY /status-app/ /idea-dist/status-app/
COPY /status-app/ /status-app/

# Create a directory for mounting a volume.
RUN mkdir /idea-server
# Create a folders structure for mounting a shared volume and copy the editor binaries to.
RUN mkdir -p /idea-server/status-app

# Adjust permissions on some items so they're writable by group root.
RUN for f in "${HOME}" "/etc/passwd" "/etc/group" "/idea-dist/status-app" "/idea-server"; do\
# Adjust the permissions on the entries which should be writable by group root.
RUN for f in "${HOME}" "/etc/passwd" "/etc/group" "/status-app" "/idea-server"; do\
chgrp -R 0 ${f} && \
chmod -R g+rwX ${f}; \
done

# Build the status app.
WORKDIR /idea-dist/status-app/
WORKDIR /status-app/
RUN npm install

# Switch to unprivileged user.
Expand Down
22 changes: 17 additions & 5 deletions build/dockerfiles/entrypoint-init-container.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh
#
# Copyright (c) 2023 Red Hat, Inc.
# Copyright (c) 2023-2024 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
Expand All @@ -11,9 +11,21 @@
# Red Hat, Inc. - initial API and implementation
#

# Copy IDEA server stuff to the shared volume.
cp -r /idea-dist/* /idea-server/
cp /entrypoint-volume.sh /idea-server/
ide_flavour="$1"
ide_server_path="/idea-server"

# Copy the editor binaries to the shared volume.

if [ -z "$ide_flavour" ]; then
# use IDEA, if none is specified
ide_flavour="idea"
fi

echo "Copying $ide_flavour"
cp -r /"$ide_flavour"-dist/* "$ide_server_path"

cp -r /status-app/ "$ide_server_path"
cp /entrypoint-volume.sh "$ide_server_path"

echo "Volume content:"
ls -la /idea-server
ls -la "$ide_server_path"
10 changes: 6 additions & 4 deletions build/dockerfiles/entrypoint-volume.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh
#
# Copyright (c) 2023 Red Hat, Inc.
# Copyright (c) 2023-2024 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
Expand All @@ -20,16 +20,18 @@ if ! whoami &> /dev/null; then
fi
fi

ide_server_path="/idea-server"

echo "Volume content:"
ls -la /idea-server/
ls -la "$ide_server_path"

# Start the app that checks the IDEA server status.
# This should be the editor's 'main' endpoint.
cd /idea-server/status-app
cd "$ide_server_path"/status-app
nohup npm start &

# Skip all interactive shell prompts.
export REMOTE_DEV_NON_INTERACTIVE=1

cd /idea-server/bin
cd "$ide_server_path"/bin
./remote-dev-server.sh run ${PROJECT_SOURCE}
12 changes: 7 additions & 5 deletions status-app/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2023 Red Hat, Inc.
* Copyright (c) 2023-2024 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
Expand All @@ -13,11 +13,12 @@
const chokidar = require('chokidar');
const fs = require("fs");
const express = require('express');
const ideInfo = require('../product-info.json');

// path to the IDEA server's output
const logsFile = '/idea-server/std.out';
// path to the IDE server's logs
const logsFile = '../std.out';

// watch for the 'Join-link' in the IDEA server's output
// watch for the 'joinLink' in the IDE server's output
var joinLink = new Promise((resolve) => {
const watcher = chokidar.watch(logsFile);
watcher.on('change', (event, path) => {
Expand All @@ -41,13 +42,14 @@ var joinLink = new Promise((resolve) => {
const app = express();
app.set('view engine', 'ejs');
app.get('/', async function (req, res) {
const ideName = ideInfo.productVendor + ' ' + ideInfo.name + ' ' + ideInfo.version;
const invitationLink = (await joinLink).replaceAll('&', '_');
const dwNamespace = process.env.DEVWORKSPACE_NAMESPACE;
const dwName = process.env.DEVWORKSPACE_NAME;
const clusterConsoleURL = process.env.CLUSTER_CONSOLE_URL;
const podName = process.env.HOSTNAME;
// render the page from EJS template
res.render('status', { dwNamespace, dwName, clusterConsoleURL, podName, invitationLink });
res.render('status', { ideName, dwNamespace, dwName, clusterConsoleURL, podName, invitationLink });
});

// server setup
Expand Down
4 changes: 2 additions & 2 deletions status-app/views/status.ejs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!--
Copyright (c) 2023 Red Hat, Inc.
Copyright (c) 2023-2024 Red Hat, Inc.
This program and the accompanying materials are made
available under the terms of the Eclipse Public License 2.0
which is available at https://www.eclipse.org/legal/epl-2.0/
Expand Down Expand Up @@ -28,7 +28,7 @@
}());
</script>

<h1>"<%= dwName %>" workspace with IntelliJ IDEA dev server is running</h1>
<h1>Workspace "<%= dwName %>" with <%= ideName %> is running</h1>

<h3>How to connect to this DevWorkspace?</h3>

Expand Down

0 comments on commit aadb4ca

Please sign in to comment.