-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Artem Zatsarynnyi <[email protected]>
- Loading branch information
1 parent
ea4ad45
commit e8a189b
Showing
10 changed files
with
1,260 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: image-publish | ||
|
||
on: | ||
push: | ||
branches: | ||
- 'main' | ||
|
||
jobs: | ||
docker: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
token: ${{ secrets.CHE_INCUBATOR_BOT_TOKEN }} | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
- name: Login to quay.io | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: quay.io | ||
username: ${{ secrets.QUAY_USERNAME }} | ||
password: ${{ secrets.QUAY_PASSWORD }} | ||
- name: Build and push image | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: . | ||
file: build/dockerfiles/Dockerfile | ||
push: true | ||
tags: quay.io/che-incubator/che-idea-dev-server:next |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,13 @@ | ||
# che-idea | ||
# IDEA dev server for Che [![Dev](https://img.shields.io/static/v1?label=Open%20in&message=Che%20dogfooding%20server%20&logo=eclipseche&color=FDB940&labelColor=525C86)](https://che-dogfooding.apps.che-dev.x6e0.p1.openshiftapps.com/f?url=https://github.com/azatsarynnyy/web-nodejs-sample/tree/idea-server&policies.create=peruser) [![Dev](https://img.shields.io/static/v1?label=Open%20in&message=DevSandbox%20(hosted%20by%20Red%20Hat)&logo=eclipseche&color=FDB940&labelColor=525C86)](https://devspaces.apps.sandbox-m4.g2pi.p1.openshiftapps.com/f?url=https://github.com/azatsarynnyy/web-nodejs-sample/tree/idea-server&policies.create=peruser) | ||
|
||
## Image build | ||
|
||
`podman build . -f build/dockerfiles/Dockerfile -t che-idea-dev-server:next` | ||
|
||
## License | ||
|
||
- [Eclipse Public License 2.0](LICENSE) | ||
|
||
## Trademark | ||
|
||
"Che" is a trademark of the Eclipse Foundation. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Copyright (c) 2023 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/ | ||
# | ||
# SPDX-License-Identifier: EPL-2.0 | ||
# | ||
# Contributors: | ||
# Red Hat, Inc. - initial API and implementation | ||
|
||
FROM registry.access.redhat.com/ubi8/nodejs-18:1-60 AS ubi-builder | ||
|
||
WORKDIR /idea-dist/ | ||
RUN curl -sL https://download-cdn.jetbrains.com/idea/ideaIU-2023.2.5.tar.gz | tar xzf - --strip-components=1 | ||
|
||
USER 0 | ||
|
||
COPY --chmod=755 /build/dockerfiles/*.sh / | ||
COPY /status-app/ /idea-dist/status-app/ | ||
|
||
# Create a directory for mounting a volume. | ||
RUN mkdir /idea-server | ||
|
||
# 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\ | ||
chgrp -R 0 ${f} && \ | ||
chmod -R g+rwX ${f}; \ | ||
done | ||
|
||
# Build the status app. | ||
WORKDIR /idea-dist/status-app/ | ||
RUN npm install | ||
|
||
# Switch to unprivileged user. | ||
USER 10001 | ||
|
||
ENTRYPOINT /entrypoint.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/sh | ||
# | ||
# Copyright (c) 2023 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/ | ||
# | ||
# SPDX-License-Identifier: EPL-2.0 | ||
# | ||
# Contributors: | ||
# 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/ | ||
|
||
echo "Volume content:" | ||
ls -la /idea-server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/bin/sh | ||
# | ||
# Copyright (c) 2023 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/ | ||
# | ||
# SPDX-License-Identifier: EPL-2.0 | ||
# | ||
# Contributors: | ||
# Red Hat, Inc. - initial API and implementation | ||
# | ||
|
||
# Register the current (arbitrary) user. | ||
if ! whoami &> /dev/null; then | ||
if [ -w /etc/passwd ]; then | ||
echo "Registering the current (arbitrary) user." | ||
echo "${USER_NAME:-user}:x:$(id -u):0:${USER_NAME:-user} user:${HOME}:/bin/bash" >> /etc/passwd | ||
echo "${USER_NAME:-user}:x:$(id -u):" >> /etc/group | ||
fi | ||
fi | ||
|
||
echo "Volume content:" | ||
ls -la /idea-server/ | ||
|
||
# Start the app that checks the IDEA server status. | ||
# This should be the editor's 'main' endpoint. | ||
cd /idea-server/status-app | ||
nohup yarn start & | ||
|
||
# Skip all interactive shell prompts. | ||
export REMOTE_DEV_NON_INTERACTIVE=1 | ||
|
||
cd /idea-server/bin | ||
./remote-dev-server.sh run ${PROJECT_SOURCE} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/sh | ||
# | ||
# Copyright (c) 2023 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/ | ||
# | ||
# SPDX-License-Identifier: EPL-2.0 | ||
# | ||
# Contributors: | ||
# Red Hat, Inc. - initial API and implementation | ||
# | ||
|
||
# Register the current (arbitrary) user. | ||
if ! whoami &> /dev/null; then | ||
if [ -w /etc/passwd ]; then | ||
echo "Registering the current (arbitrary) user." | ||
echo "${USER_NAME:-user}:x:$(id -u):0:${USER_NAME:-user} user:${HOME}:/bin/bash" >> /etc/passwd | ||
echo "${USER_NAME:-user}:x:$(id -u):" >> /etc/group | ||
fi | ||
fi | ||
|
||
# Skip all interactive shell prompts. | ||
export REMOTE_DEV_NON_INTERACTIVE=1 | ||
|
||
cd /idea-dist/bin | ||
./remote-dev-server.sh run ~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/** | ||
* Copyright (c) 2023 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/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Red Hat, Inc. - initial API and implementation | ||
*/ | ||
|
||
const chokidar = require('chokidar'); | ||
const fs = require("fs"); | ||
const express = require('express'); | ||
|
||
// path to the IDEA server's output | ||
const logsFile = '/idea-server/std.out'; | ||
|
||
// watch for the 'Join-link' in the IDEA server's output | ||
var joinLink = new Promise((resolve) => { | ||
const watcher = chokidar.watch(logsFile); | ||
watcher.on('change', (event, path) => { | ||
fs.readFile(logsFile, "utf-8", (err, data) => { | ||
if (err) | ||
throw err; | ||
|
||
if (data.includes('Join link: tcp://')) { | ||
const tcpLinkRegex = /(tcp:\/\/[^\s]+)/g; | ||
data.replace(tcpLinkRegex, function (link) { | ||
console.log('TCP join link is accuired: ' + link); | ||
resolve(link); | ||
watcher.close().then(() => console.log('Watcher is closed!')); | ||
}); | ||
} | ||
}); | ||
}); | ||
}); | ||
|
||
// return the status page | ||
const app = express(); | ||
app.set('view engine', 'ejs'); | ||
app.get('/', async function (req, res) { | ||
const invitationLink = await joinLink; | ||
const dwName = process.env.DEVWORKSPACE_NAME; | ||
const clusterConsoleURL = process.env.CLUSTER_CONSOLE_URL; | ||
const podName = process.env.HOSTNAME; | ||
|
||
res.render('status', { dwName, clusterConsoleURL, podName, invitationLink }); | ||
}); | ||
|
||
// server setup | ||
const appPort = '3100'; | ||
app.listen(appPort, function (err) { | ||
if (err) | ||
throw err; | ||
|
||
console.log('Status app is listening on port', appPort); | ||
}); |
Oops, something went wrong.