Skip to content

Commit

Permalink
Added devfile component and commands
Browse files Browse the repository at this point in the history
  • Loading branch information
l0rd committed Dec 6, 2023
1 parent f09c1f3 commit 855176e
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 14 deletions.
40 changes: 40 additions & 0 deletions .devfile.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
schemaVersion: 2.2.0
metadata:
name: jetbrains-editor-images
components:
- name: devtools
container:
image: quay.io/devfile/universal-developer-image:latest
cpuLimit: '4'
memoryLimit: 12Gi
env:
- name: DOCKER
value: podman
- name: KUBEDOCK_ENABLED
value: 'true'
commands:
- id: generic-build
exec:
commandLine: ./projector.sh build
component: devtools
label: Interactive build of supported JetBrains IDEs
- id: goland-build
exec:
commandLine: ./projector.sh build --url https://download.jetbrains.com/go/goland-2021.3.3.tar.gz --tag quay.io/che-incubator/che-goland:2021.3
component: devtools
label: Build of JetBrains GoLand container image
- id: raider-build
exec:
commandLine: ./projector.sh build --url https://download.jetbrains.com/rider/JetBrains.Rider-2021.3.3.tar.gz --tag quay.io/che-incubator/che-rider:2021.3
component: devtools
label: Build of JetBrains Raider container image
- id: intellij-ultimate-build
exec:
commandLine: ./projector.sh build --url https://download.jetbrains.com/idea/ideaIU-2021.3.2.tar.gz --tag quay.io/che-incubator/che-ideaiu:2021.3
component: devtools
label: Build of JetBrains IntelliJ Ultimate container image
- id: intellij-run
exec:
commandLine: podman run -p 8887:8887 -d quay.io/che-incubator/che-idea:next
component: devtools
label: Run of JetBrains IntelliJ
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ RUN unzip asset-projector-server-assembly.zip && rm asset-projector-server-assem
find . -maxdepth 1 -type d -name projector-server-* -exec mv {} ide/projector-server \;

COPY --chown=0:0 asset-static-assembly.tar.gz .
RUN tar -xf asset-static-assembly.tar.gz && rm asset-static-assembly.tar.gz && \
RUN tar --no-same-owner -xf asset-static-assembly.tar.gz && rm asset-static-assembly.tar.gz && \
chown -R 0:0 static && \
mv static/* . && rm -rf static && \
chmod +x *.sh && \
Expand Down
3 changes: 0 additions & 3 deletions devfile.yaml

This file was deleted.

22 changes: 12 additions & 10 deletions projector.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ MACHINE_EXEC_ASSET_DEST="$base_dir"/asset-machine-exec

DOC_URL=https://github.com/che-incubator/jetbrains-editor-images/tree/main/doc

DOCKER=${DOCKER:-docker}

# Logging configuration
# https://en.wikipedia.org/wiki/Syslog#Severity_level
_RD='\033[0;31m' # Red
Expand Down Expand Up @@ -220,7 +222,7 @@ EOM
log:debug "$PRE_BUILD_SUMMARY"
log:info "Build '$PROJECTOR_SERVER_IMAGE'"

docker build --progress="$PROGRESS" -f build/dockerfiles/projector-server-builder.Dockerfile -t "$PROJECTOR_SERVER_IMAGE" .
"${DOCKER}" build --progress="$PROGRESS" -f build/dockerfiles/projector-server-builder.Dockerfile -t "$PROJECTOR_SERVER_IMAGE" .
# shellcheck disable=SC2181
if [[ $? -eq 0 ]]; then
log:info "Container '$PROJECTOR_SERVER_IMAGE' successfully built"
Expand Down Expand Up @@ -248,7 +250,7 @@ EOM
log:debug "$PRE_BUILD_SUMMARY"
log:info "Build '$PLUGIN_BUILDER_IMAGE'"

docker build --progress="$PROGRESS" -f build/dockerfiles/che-plugin-builder.Dockerfile -t "$PLUGIN_BUILDER_IMAGE" .
"${DOCKER}" build --progress="$PROGRESS" -f build/dockerfiles/che-plugin-builder.Dockerfile -t "$PLUGIN_BUILDER_IMAGE" .
# shellcheck disable=SC2181
if [[ $? -eq 0 ]]; then
log:info "Container '$PLUGIN_BUILDER_IMAGE' successfully built"
Expand Down Expand Up @@ -276,7 +278,7 @@ EOM
log:debug "$PRE_BUILD_SUMMARY"
log:info "Build '$MACHINE_EXEC_IMAGE'"

docker build --progress="$PROGRESS" -f build/dockerfiles/machine-exec-provider.Dockerfile -t "$MACHINE_EXEC_IMAGE" .
"${DOCKER}" build --progress="$PROGRESS" -f build/dockerfiles/machine-exec-provider.Dockerfile -t "$MACHINE_EXEC_IMAGE" .
# shellcheck disable=SC2181
if [[ $? -eq 0 ]]; then
log:info "Container '$MACHINE_EXEC_IMAGE' successfully built"
Expand All @@ -302,7 +304,7 @@ EOM
log:info "Build '$CONTAINER_TAG'"

DOCKER_BUILDKIT=1 \
docker build \
"${DOCKER}" build \
--progress="$PROGRESS" \
-t "$CONTAINER_TAG" \
-f Dockerfile .
Expand All @@ -328,7 +330,7 @@ runContainerImage() {
done <<<"$mountVolumes"

log:info "Run container '$containerToStart'"
docker run --rm -p 8887:8887 "${mountOptions[@]}" -it "$containerToStart" 2>&1 | awk '{print " "$0}'
"${DOCKER}" run --rm -p 8887:8887 "${mountOptions[@]}" -it "$containerToStart" 2>&1 | awk '{print " "$0}'
}

saveImageOnBuild() {
Expand All @@ -338,7 +340,7 @@ saveImageOnBuild() {
fi
local imageOutputName && imageOutputName=$(basename "$URL")
log:info "Saving '$CONTAINER_TAG' to '$SAVE_ON_BUILD_DIRECTORY/$imageOutputName'"
docker save "$CONTAINER_TAG" -o "$SAVE_ON_BUILD_DIRECTORY"/"$imageOutputName"
"${DOCKER}" save "$CONTAINER_TAG" -o "$SAVE_ON_BUILD_DIRECTORY"/"$imageOutputName"
log:info "Image '$CONTAINER_TAG' saved to '$SAVE_ON_BUILD_DIRECTORY/$imageOutputName'"
fi
}
Expand Down Expand Up @@ -378,7 +380,7 @@ EOM
log:debug "$PRE_BUILD_SUMMARY"
log:info "Build '$IDE_DOWNLOADER_IMAGE'"

docker build --progress="$PROGRESS" -f build/dockerfiles/ide-downloader.Dockerfile --build-arg "URL=$URL" -t "$IDE_DOWNLOADER_IMAGE" .
"${DOCKER}" build --progress="$PROGRESS" -f build/dockerfiles/ide-downloader.Dockerfile --build-arg "URL=$URL" -t "$IDE_DOWNLOADER_IMAGE" .
# shellcheck disable=SC2181
if [[ $? -eq 0 ]]; then
log:info "Container '$IDE_DOWNLOADER_IMAGE' successfully built"
Expand Down Expand Up @@ -459,8 +461,8 @@ extractFromContainer() {
tmpContainer="$(echo "$1" | tr "/:" "--")-$(date +%s)"

log:info "Using temporary container '$tmpContainer'"
docker create --name="$tmpContainer" "$1" sh >/dev/null 2>&1
docker export "$tmpContainer" > "/tmp/$tmpContainer.tar"
"${DOCKER}" create --name="$tmpContainer" "$1" sh >/dev/null 2>&1
"${DOCKER}" export "$tmpContainer" > "/tmp/$tmpContainer.tar"

tmpDir="/tmp/$tmpContainer"
log:info "Created temporary directory '$tmpDir'"
Expand All @@ -474,7 +476,7 @@ extractFromContainer() {
mv "$tmpDir/$2" "$3"

log:info "Clean up the temporary container and directory"
docker rm -f "$tmpContainer" >/dev/null 2>&1
"${DOCKER}" rm -f "$tmpContainer" >/dev/null 2>&1
rm -rf "/tmp/$tmpContainer.tar"
rm -rf "$tmpDir" || true
}
Expand Down

0 comments on commit 855176e

Please sign in to comment.