Skip to content

Commit

Permalink
Provide sidecar-less model
Browse files Browse the repository at this point in the history
Signed-off-by: Vladyslav Zhukovskyi <vzhukovs@redhat.com>
  • Loading branch information
vzhukovs committed Jan 11, 2022
1 parent 1401ed3 commit 8b1cce7
Show file tree
Hide file tree
Showing 13 changed files with 102 additions and 94 deletions.
120 changes: 58 additions & 62 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,71 +30,67 @@
# * asset-ide-packaging.tar.gz - IDE packaging downloaded previously;
# * asset-projector-server-assembly.zip - Projector Server assembly;
# * asset-static-assembly.tar.gz - archived `static/` directory.
# https://access.redhat.com/containers/?tab=tags#/registry.access.redhat.com/ubi8-minimal
FROM registry.access.redhat.com/ubi8-minimal:8.5-218 as projectorAssembly
ENV PROJECTOR_ASSEMBLY_DIR /projector
COPY asset-ide-packaging.tar.gz /tmp/ide-unpacked/
COPY asset-projector-server-assembly.zip $PROJECTOR_ASSEMBLY_DIR/
COPY asset-static-assembly.tar.gz $PROJECTOR_ASSEMBLY_DIR/
RUN set -ex \
&& microdnf install -y --nodocs findutils tar gzip unzip \
&& cd /tmp/ide-unpacked \
&& tar xf asset-ide-packaging.tar.gz \
&& rm asset-ide-packaging.tar.gz \
&& find . -maxdepth 1 -type d -name * -exec mv {} $PROJECTOR_ASSEMBLY_DIR/ide \; \
&& cd $PROJECTOR_ASSEMBLY_DIR \
&& rm -rf /tmp/ide-unpacked \
&& unzip asset-projector-server-assembly.zip \
&& rm asset-projector-server-assembly.zip \
&& 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 asset-static-assembly.tar.gz \
&& rm asset-static-assembly.tar.gz \
&& 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 {} \; \
&& mv projector-user/.config .default \
&& rm -rf projector-user
# https://access.redhat.com/containers/?tab=tags#/registry.access.redhat.com/ubi8
FROM registry.access.redhat.com/ubi8/ubi:8.5-214 as ubi-builder
RUN mkdir -p /mnt/rootfs
RUN yum install unzip -y --nodocs && \
if [[ $(uname -m) == "s390x" ]]; then LIBSECRET="\
https://rpmfind.net/linux/fedora-secondary/releases/34/Everything/s390x/os/Packages/l/libsecret-0.20.4-2.fc34.s390x.rpm \
https://rpmfind.net/linux/fedora-secondary/releases/34/Everything/s390x/os/Packages/l/libsecret-devel-0.20.4-2.fc34.s390x.rpm \
glib2-devel pcre-cpp pcre-devel pcre-utf16 pcre-utf32"; \
elif [[ $(uname -m) == "ppc64le" ]]; then LIBSECRET="\
https://rpmfind.net/linux/centos/8-stream/BaseOS/ppc64le/os/Packages/libsecret-devel-0.18.6-1.el8.ppc64le.rpm \
libsecret"; \
elif [[ $(uname -m) == "x86_64" ]]; then LIBSECRET="\
https://rpmfind.net/linux/centos/8-stream/BaseOS/x86_64/os/Packages/libsecret-devel-0.18.6-1.el8.x86_64.rpm \
libsecret"; \
fi && \
yum install --installroot /mnt/rootfs \
brotli libstdc++ coreutils glibc-minimal-langpack \
jq shadow-utils wget git nss procps findutils which socat \
java-11-openjdk-devel \
python2 python39 \
libXext libXrender libXtst libXi \
$LIBSECRET \
--releasever 8 --setopt install_weak_deps=false --nodocs -y && \
yum --installroot /mnt/rootfs clean all
RUN rm -rf /mnt/rootfs/var/cache/* /mnt/rootfs/var/log/dnf* /mnt/rootfs/var/log/yum.*

RUN mkdir -p /mnt/rootfs/projects && mkdir -p /mnt/rootfs/home/projector && mkdir -p /mnt/rootfs/projector && \
cat /mnt/rootfs/etc/passwd | sed s#root:x.*#root:x:\${USER_ID}:\${GROUP_ID}::\${HOME}:/bin/bash#g > /mnt/rootfs/home/projector/.passwd.template && \
cat /mnt/rootfs/etc/group | sed s#root:x:0:#root:x:0:0,\${USER_ID}:#g > /mnt/rootfs/home/projector/.group.template

WORKDIR /mnt/rootfs/projector

COPY --chown=0:0 asset-ide-packaging.tar.gz .
RUN tar -xf asset-ide-packaging.tar.gz && rm asset-ide-packaging.tar.gz && \
find . -maxdepth 1 -type d -name * -exec mv {} ide \;

COPY --chown=0:0 asset-projector-server-assembly.zip .
RUN unzip asset-projector-server-assembly.zip && rm asset-projector-server-assembly.zip && \
find . -maxdepth 1 -type d -name projector-server-* -exec mv {} ide/projector-server \;

# Stage 2. Build the main image with necessary environment for running Projector
# Doesn't require to be a desktop environment. Projector runs in headless mode.
COPY --chown=0:0 asset-static-assembly.tar.gz .
RUN tar -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 && \
mv ide-projector-launcher.sh ide/bin && \
mv config ide/

RUN for f in "/mnt/rootfs/bin/" "/mnt/rootfs/home/projector" "/mnt/rootfs/etc/passwd" "/mnt/rootfs/etc/group" "/mnt/rootfs/projects" "/mnt/rootfs/projector/ide/bin" ; do\
chgrp -R 0 ${f} && \
chmod -R g+rwX ${f}; \
done


# Stage 2. Copy from build environment Projector assembly to the runtime. Projector runs in headless mode.
# https://access.redhat.com/containers/?tab=tags#/registry.access.redhat.com/ubi8-minimal
FROM registry.access.redhat.com/ubi8-minimal:8.5-218
ENV USER projector
ENV HOME /home/$USER
ENV HOME=/home/projector
ENV PROJECTOR_ASSEMBLY_DIR /projector
ENV PROJECTOR_CONFIG_DIR $HOME/.config
COPY install-platform-dependencies.sh /tmp
RUN set -ex \
&& microdnf install -y --nodocs \
jq shadow-utils wget git nss procps findutils which socat \
# Java 11 support
java-11-openjdk-devel \
# Python support
python2 python39 \
# Packages needed for AWT.
libXext libXrender libXtst libXi \
# Arch specific installs of libsecret and libsecret-devel (required by JetBrains products)
&& chmod +x /tmp/install-platform-dependencies.sh && /tmp/install-platform-dependencies.sh && rm -f /tmp/install-platform-dependencies.sh \
# create user configuration
&& adduser -r -u 1002 -G root -d $HOME -m -s /bin/sh $USER \
&& echo "%wheel ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers \
&& mkdir /projects \
&& for f in "${HOME}" "/etc/passwd" "/etc/group /projects"; do\
chgrp -R 0 ${f} && \
chmod -R g+rwX ${f}; \
done \
&& cat /etc/passwd | sed s#root:x.*#root:x:\${USER_ID}:\${GROUP_ID}::\${HOME}:/bin/bash#g > ${HOME}/passwd.template \
&& cat /etc/group | sed s#root:x:0:#root:x:0:0,\${USER_ID}:#g > ${HOME}/group.template \
# Change permissions to allow editing of files for openshift user
&& find $HOME -exec chgrp 0 {} \; -exec chmod g+rwX {} \;

COPY --chown=$USER:root --from=projectorAssembly $PROJECTOR_ASSEMBLY_DIR $PROJECTOR_ASSEMBLY_DIR

USER $USER
WORKDIR /projects
ENV PROJECTOR_CONFIG_DIR $HOME/.jetbrains
COPY --from=ubi-builder /mnt/rootfs/ /
USER 1001
EXPOSE 8887
ENTRYPOINT $PROJECTOR_ASSEMBLY_DIR/entrypoint.sh
27 changes: 0 additions & 27 deletions install-platform-dependencies.sh

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
20 changes: 20 additions & 0 deletions static/entrypoint-init-container.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash
#
# Copyright (c) 2022 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
#

# necessary environment variables: PROJECTOR_VOLUME_MOUNT and PROJECTOR_ASSEMBLY_DIR
if [ -n "$PROJECTOR_VOLUME_MOUNT" ] || [ -n "$PROJECTOR_ASSEMBLY_DIR" ]; then
echo "Found environment variable PROJECTOR_VOLUME_MOUNT: $PROJECTOR_VOLUME_MOUNT"
echo "Found environment variable PROJECTOR_ASSEMBLY_DIR: $PROJECTOR_ASSEMBLY_DIR"
cp -r "$PROJECTOR_ASSEMBLY_DIR"/* "$PROJECTOR_VOLUME_MOUNT"
echo "Listing all copied files: "
ls -lah "$PROJECTOR_VOLUME_MOUNT"
else
echo "Environment variable PROJECTOR_VOLUME_MOUNT or PROJECTOR_ASSEMBLY_DIR is not set"
fi
17 changes: 17 additions & 0 deletions static/entrypoint-volume.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash
#
# Copyright (c) 2022 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
#

# necessary environment variable: PROJECTOR_ASSEMBLY_DIR
if [ -n "$PROJECTOR_ASSEMBLY_DIR" ]; then
cd "$PROJECTOR_ASSEMBLY_DIR"/ide/bin || exit
./ide-projector-launcher.sh
else
echo "Environment variable PROJECTOR_ASSEMBLY_DIR is not set"
fi
3 changes: 2 additions & 1 deletion static/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ if ! whoami &> /dev/null; then
fi
fi

cd /projector/ide/bin || exit
# PROJECTOR_ASSEMBLY_DIR env variable provided by Docker environment
cd "$PROJECTOR_ASSEMBLY_DIR"/ide/bin || exit

./ide-projector-launcher.sh
9 changes: 5 additions & 4 deletions static/ide-projector-launcher.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
#
# Copyright (c) 2021 Red Hat, Inc.
# Copyright (c) 2022 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 @@ -26,8 +26,9 @@

# copy default configuration if it doesn't exist
if [ ! -d "$PROJECTOR_CONFIG_DIR" ]; then
echo "Copy default configuration '$PROJECTOR_ASSEMBLY_DIR/.default' to '$PROJECTOR_CONFIG_DIR'."
cp -rp "$PROJECTOR_ASSEMBLY_DIR"/.default "$PROJECTOR_CONFIG_DIR"
echo "Copy default configuration '$PROJECTOR_ASSEMBLY_DIR/ide/config' to '$PROJECTOR_CONFIG_DIR'."
mkdir -p "$PROJECTOR_CONFIG_DIR"
cp -rp "$PROJECTOR_ASSEMBLY_DIR"/ide/config "$PROJECTOR_CONFIG_DIR"/
fi

# overwrite default configuration paths for IDE
Expand Down Expand Up @@ -121,7 +122,7 @@ sed -i 's+classpath "$CLASSPATH"+classpath "$CLASSPATH:$IDE_HOME/projector-serve
# -Dorg.jetbrains.projector.server.classToLaunch=com.intellij.idea.Main org.jetbrains.projector.server.ProjectorLauncher
sed -i 's+com.intellij.idea.Main+-Dorg.jetbrains.projector.server.classToLaunch=com.intellij.idea.Main org.jetbrains.projector.server.ProjectorLauncher+g' "$IDE_RUN_FILE_NAME-projector.sh"

bash "$IDE_RUN_FILE_NAME-projector.sh"
bash "$IDE_RUN_FILE_NAME-projector.sh" "nosplash"

rm "$IDE_RUN_FILE_NAME-projector.sh"

0 comments on commit 8b1cce7

Please sign in to comment.