From b3de2e49926e2808f73fd12767d1069a6a35f3d0 Mon Sep 17 00:00:00 2001 From: Vladyslav Zhukovskyi Date: Tue, 27 Jul 2021 14:16:31 +0300 Subject: [PATCH] Prepare Dockerfile to build in OSBS Signed-off-by: Vladyslav Zhukovskyi --- .dockerignore | 6 +++--- .gitignore | 4 +++- CHANGELOG.md | 2 +- Dockerfile | 23 +++++++++++++++-------- projector.sh | 19 +++++++++++++++++-- 5 files changed, 39 insertions(+), 15 deletions(-) diff --git a/.dockerignore b/.dockerignore index a7e2393a..fae2725d 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,5 +1,5 @@ ** -!/build/ide-packaging -!/build/projector-server-assembly -!/static/** +!/ide-packaging +!/projector-server-assembly +!/static-assembly diff --git a/.gitignore b/.gitignore index c822166a..f97e7b0e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ .DS_Store .idea *.iml -*.tar.gz build +ide-packaging +projector-server-assembly +static-assembly diff --git a/CHANGELOG.md b/CHANGELOG.md index a0f2ccdb..bdf09a1d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,7 @@ This document reflects the project's changes made after each release cycle ### Changed -- TBD +- Prepare Dockerfile to build in OSBS ([#43](https://github.com/che-incubator/jetbrains-editor-images/pull/43)) ### Fixed diff --git a/Dockerfile b/Dockerfile index 3006fcf5..99acde11 100644 --- a/Dockerfile +++ b/Dockerfile @@ -26,25 +26,32 @@ # $ ./projector.sh build [OPTIONS] # Stage 1. Prepare JetBrains IDE with Projector. -# Requires build/ide-packaging which should point to the ide packaging downloaded -# previously, usually tar.gz archive. Also requires build/projector-server-assembly -# which points to the built Projector Server assembly. +# Requires ide-packaging which should point to the ide packaging downloaded +# previously, usually tar.gz archive. Also requires projector-server-assembly +# which points to the built Projector Server assembly, zip archive. Requires +# static-assembly a gzipped static directory. FROM registry.access.redhat.com/ubi8-minimal:8.4-205 as projectorAssembly ENV PROJECTOR_DIR /projector -ADD build/ide-packaging /tmp/ide-unpacked -ADD build/projector-server-assembly $PROJECTOR_DIR/projector-server.zip -ADD static $PROJECTOR_DIR +COPY ide-packaging /tmp/ide-unpacked/ +COPY projector-server-assembly $PROJECTOR_DIR/ +COPY static-assembly $PROJECTOR_DIR/ RUN set -ex \ && microdnf install -y --nodocs findutils tar gzip unzip \ && cd /tmp/ide-unpacked \ + && tar xf ide-packaging \ + && rm ide-packaging \ && find . -maxdepth 1 -type d -name * -exec mv {} $PROJECTOR_DIR/ide \; \ && cd $PROJECTOR_DIR \ && rm -rf /tmp/ide-unpacked \ - && unzip projector-server.zip \ - && rm projector-server.zip \ + && unzip projector-server-assembly \ + && rm projector-server-assembly \ && find . -maxdepth 1 -type d -name projector-server-* -exec mv {} projector-server \; \ && mv projector-server ide/projector-server \ && chmod 644 ide/projector-server/lib/* \ + && tar -xf static-assembly \ + && rm static-assembly \ + && mv static/* . \ + && rm -rf static \ && mv ide-projector-launcher.sh ide/bin \ && find . -exec chgrp 0 {} \; -exec chmod g+rwX {} \; \ && find . -name "*.sh" -exec chmod +x {} \; \ diff --git a/projector.sh b/projector.sh index 32ab7f26..34de0d7c 100755 --- a/projector.sh +++ b/projector.sh @@ -25,8 +25,9 @@ RUN_ON_BUILD=false SAVE_ON_BUILD=false SAVE_ON_BUILD_DIRECTORY="$BUILD_DIRECTORY"/docker IDE_PACKAGING_DIRECTORY="$BUILD_DIRECTORY"/ide -CURRENT_IDE_PACKAGING_SYMLINK="$BUILD_DIRECTORY"/ide-packaging -CURRENT_PROJECTOR_ASSEMBLY_SYMLINK="$BUILD_DIRECTORY"/projector-server-assembly +CURRENT_IDE_PACKAGING_SYMLINK="$base_dir"/ide-packaging +CURRENT_PROJECTOR_ASSEMBLY_SYMLINK="$base_dir"/projector-server-assembly +CURRENT_PROJECTOR_STATIC_ASSEMBLY="$base_dir"/static-assembly PROGRESS=auto CONFIG_JSON=compatible-ide.json CONFIG_JSON_PATH="$base_dir"/"$CONFIG_JSON" @@ -347,6 +348,18 @@ runOnBuild() { fi } +prepareStaticFiles() { + cd "$base_dir" || exit 1 + .log 7 "Current working directory '$(pwd)'" + if [ -f "$CURRENT_PROJECTOR_STATIC_ASSEMBLY" ]; then + .log 7 "Removing symlink '$CURRENT_PROJECTOR_STATIC_ASSEMBLY'" + rm "$CURRENT_PROJECTOR_STATIC_ASSEMBLY" + fi + + .log 7 "Creating archive for Projector static files '$CURRENT_PROJECTOR_STATIC_ASSEMBLY'" + tar -czf "$CURRENT_PROJECTOR_STATIC_ASSEMBLY" static +} + prepareAssembly() { if [ -z "$URL" ]; then .log 7 "Ignoring --tag and --url option" @@ -355,6 +368,7 @@ prepareAssembly() { # Run interactive wizard to choose IDE packaging from predefined configuration selectPackagingFromPredefinedConfig fi + prepareStaticFiles downloadIdePackaging checkProjectorSourcesExist projectorBuild @@ -393,6 +407,7 @@ buildContainerImage() { selectPackagingFromPredefinedConfig fi + prepareStaticFiles downloadIdePackaging checkProjectorSourcesExist projectorBuild