Skip to content

Commit 8b1cce7

Browse files
committed
Provide sidecar-less model
Signed-off-by: Vladyslav Zhukovskyi <vzhukovs@redhat.com>
1 parent 1401ed3 commit 8b1cce7

13 files changed

+102
-94
lines changed

Dockerfile

+58-62
Original file line numberDiff line numberDiff line change
@@ -30,71 +30,67 @@
3030
# * asset-ide-packaging.tar.gz - IDE packaging downloaded previously;
3131
# * asset-projector-server-assembly.zip - Projector Server assembly;
3232
# * asset-static-assembly.tar.gz - archived `static/` directory.
33-
# https://access.redhat.com/containers/?tab=tags#/registry.access.redhat.com/ubi8-minimal
34-
FROM registry.access.redhat.com/ubi8-minimal:8.5-218 as projectorAssembly
35-
ENV PROJECTOR_ASSEMBLY_DIR /projector
36-
COPY asset-ide-packaging.tar.gz /tmp/ide-unpacked/
37-
COPY asset-projector-server-assembly.zip $PROJECTOR_ASSEMBLY_DIR/
38-
COPY asset-static-assembly.tar.gz $PROJECTOR_ASSEMBLY_DIR/
39-
RUN set -ex \
40-
&& microdnf install -y --nodocs findutils tar gzip unzip \
41-
&& cd /tmp/ide-unpacked \
42-
&& tar xf asset-ide-packaging.tar.gz \
43-
&& rm asset-ide-packaging.tar.gz \
44-
&& find . -maxdepth 1 -type d -name * -exec mv {} $PROJECTOR_ASSEMBLY_DIR/ide \; \
45-
&& cd $PROJECTOR_ASSEMBLY_DIR \
46-
&& rm -rf /tmp/ide-unpacked \
47-
&& unzip asset-projector-server-assembly.zip \
48-
&& rm asset-projector-server-assembly.zip \
49-
&& find . -maxdepth 1 -type d -name projector-server-* -exec mv {} projector-server \; \
50-
&& mv projector-server ide/projector-server \
51-
&& chmod 644 ide/projector-server/lib/* \
52-
&& tar -xf asset-static-assembly.tar.gz \
53-
&& rm asset-static-assembly.tar.gz \
54-
&& mv static/* . \
55-
&& rm -rf static \
56-
&& mv ide-projector-launcher.sh ide/bin \
57-
&& find . -exec chgrp 0 {} \; -exec chmod g+rwX {} \; \
58-
&& find . -name "*.sh" -exec chmod +x {} \; \
59-
&& mv projector-user/.config .default \
60-
&& rm -rf projector-user
33+
# https://access.redhat.com/containers/?tab=tags#/registry.access.redhat.com/ubi8
34+
FROM registry.access.redhat.com/ubi8/ubi:8.5-214 as ubi-builder
35+
RUN mkdir -p /mnt/rootfs
36+
RUN yum install unzip -y --nodocs && \
37+
if [[ $(uname -m) == "s390x" ]]; then LIBSECRET="\
38+
https://rpmfind.net/linux/fedora-secondary/releases/34/Everything/s390x/os/Packages/l/libsecret-0.20.4-2.fc34.s390x.rpm \
39+
https://rpmfind.net/linux/fedora-secondary/releases/34/Everything/s390x/os/Packages/l/libsecret-devel-0.20.4-2.fc34.s390x.rpm \
40+
glib2-devel pcre-cpp pcre-devel pcre-utf16 pcre-utf32"; \
41+
elif [[ $(uname -m) == "ppc64le" ]]; then LIBSECRET="\
42+
https://rpmfind.net/linux/centos/8-stream/BaseOS/ppc64le/os/Packages/libsecret-devel-0.18.6-1.el8.ppc64le.rpm \
43+
libsecret"; \
44+
elif [[ $(uname -m) == "x86_64" ]]; then LIBSECRET="\
45+
https://rpmfind.net/linux/centos/8-stream/BaseOS/x86_64/os/Packages/libsecret-devel-0.18.6-1.el8.x86_64.rpm \
46+
libsecret"; \
47+
fi && \
48+
yum install --installroot /mnt/rootfs \
49+
brotli libstdc++ coreutils glibc-minimal-langpack \
50+
jq shadow-utils wget git nss procps findutils which socat \
51+
java-11-openjdk-devel \
52+
python2 python39 \
53+
libXext libXrender libXtst libXi \
54+
$LIBSECRET \
55+
--releasever 8 --setopt install_weak_deps=false --nodocs -y && \
56+
yum --installroot /mnt/rootfs clean all
57+
RUN rm -rf /mnt/rootfs/var/cache/* /mnt/rootfs/var/log/dnf* /mnt/rootfs/var/log/yum.*
58+
59+
RUN mkdir -p /mnt/rootfs/projects && mkdir -p /mnt/rootfs/home/projector && mkdir -p /mnt/rootfs/projector && \
60+
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 && \
61+
cat /mnt/rootfs/etc/group | sed s#root:x:0:#root:x:0:0,\${USER_ID}:#g > /mnt/rootfs/home/projector/.group.template
62+
63+
WORKDIR /mnt/rootfs/projector
64+
65+
COPY --chown=0:0 asset-ide-packaging.tar.gz .
66+
RUN tar -xf asset-ide-packaging.tar.gz && rm asset-ide-packaging.tar.gz && \
67+
find . -maxdepth 1 -type d -name * -exec mv {} ide \;
68+
69+
COPY --chown=0:0 asset-projector-server-assembly.zip .
70+
RUN unzip asset-projector-server-assembly.zip && rm asset-projector-server-assembly.zip && \
71+
find . -maxdepth 1 -type d -name projector-server-* -exec mv {} ide/projector-server \;
6172

62-
# Stage 2. Build the main image with necessary environment for running Projector
63-
# Doesn't require to be a desktop environment. Projector runs in headless mode.
73+
COPY --chown=0:0 asset-static-assembly.tar.gz .
74+
RUN tar -xf asset-static-assembly.tar.gz && rm asset-static-assembly.tar.gz && \
75+
chown -R 0:0 static && \
76+
mv static/* . && rm -rf static && \
77+
chmod +x *.sh && \
78+
mv ide-projector-launcher.sh ide/bin && \
79+
mv config ide/
80+
81+
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\
82+
chgrp -R 0 ${f} && \
83+
chmod -R g+rwX ${f}; \
84+
done
85+
86+
87+
# Stage 2. Copy from build environment Projector assembly to the runtime. Projector runs in headless mode.
6488
# https://access.redhat.com/containers/?tab=tags#/registry.access.redhat.com/ubi8-minimal
6589
FROM registry.access.redhat.com/ubi8-minimal:8.5-218
66-
ENV USER projector
67-
ENV HOME /home/$USER
90+
ENV HOME=/home/projector
6891
ENV PROJECTOR_ASSEMBLY_DIR /projector
69-
ENV PROJECTOR_CONFIG_DIR $HOME/.config
70-
COPY install-platform-dependencies.sh /tmp
71-
RUN set -ex \
72-
&& microdnf install -y --nodocs \
73-
jq shadow-utils wget git nss procps findutils which socat \
74-
# Java 11 support
75-
java-11-openjdk-devel \
76-
# Python support
77-
python2 python39 \
78-
# Packages needed for AWT.
79-
libXext libXrender libXtst libXi \
80-
# Arch specific installs of libsecret and libsecret-devel (required by JetBrains products)
81-
&& chmod +x /tmp/install-platform-dependencies.sh && /tmp/install-platform-dependencies.sh && rm -f /tmp/install-platform-dependencies.sh \
82-
# create user configuration
83-
&& adduser -r -u 1002 -G root -d $HOME -m -s /bin/sh $USER \
84-
&& echo "%wheel ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers \
85-
&& mkdir /projects \
86-
&& for f in "${HOME}" "/etc/passwd" "/etc/group /projects"; do\
87-
chgrp -R 0 ${f} && \
88-
chmod -R g+rwX ${f}; \
89-
done \
90-
&& cat /etc/passwd | sed s#root:x.*#root:x:\${USER_ID}:\${GROUP_ID}::\${HOME}:/bin/bash#g > ${HOME}/passwd.template \
91-
&& cat /etc/group | sed s#root:x:0:#root:x:0:0,\${USER_ID}:#g > ${HOME}/group.template \
92-
# Change permissions to allow editing of files for openshift user
93-
&& find $HOME -exec chgrp 0 {} \; -exec chmod g+rwX {} \;
94-
95-
COPY --chown=$USER:root --from=projectorAssembly $PROJECTOR_ASSEMBLY_DIR $PROJECTOR_ASSEMBLY_DIR
96-
97-
USER $USER
98-
WORKDIR /projects
92+
ENV PROJECTOR_CONFIG_DIR $HOME/.jetbrains
93+
COPY --from=ubi-builder /mnt/rootfs/ /
94+
USER 1001
9995
EXPOSE 8887
10096
ENTRYPOINT $PROJECTOR_ASSEMBLY_DIR/entrypoint.sh

install-platform-dependencies.sh

-27
This file was deleted.

static/entrypoint-init-container.sh

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
#
3+
# Copyright (c) 2022 Red Hat, Inc.
4+
# This program and the accompanying materials are made
5+
# available under the terms of the Eclipse Public License 2.0
6+
# which is available at https://www.eclipse.org/legal/epl-2.0/
7+
#
8+
# SPDX-License-Identifier: EPL-2.0
9+
#
10+
11+
# necessary environment variables: PROJECTOR_VOLUME_MOUNT and PROJECTOR_ASSEMBLY_DIR
12+
if [ -n "$PROJECTOR_VOLUME_MOUNT" ] || [ -n "$PROJECTOR_ASSEMBLY_DIR" ]; then
13+
echo "Found environment variable PROJECTOR_VOLUME_MOUNT: $PROJECTOR_VOLUME_MOUNT"
14+
echo "Found environment variable PROJECTOR_ASSEMBLY_DIR: $PROJECTOR_ASSEMBLY_DIR"
15+
cp -r "$PROJECTOR_ASSEMBLY_DIR"/* "$PROJECTOR_VOLUME_MOUNT"
16+
echo "Listing all copied files: "
17+
ls -lah "$PROJECTOR_VOLUME_MOUNT"
18+
else
19+
echo "Environment variable PROJECTOR_VOLUME_MOUNT or PROJECTOR_ASSEMBLY_DIR is not set"
20+
fi

static/entrypoint-volume.sh

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
#
3+
# Copyright (c) 2022 Red Hat, Inc.
4+
# This program and the accompanying materials are made
5+
# available under the terms of the Eclipse Public License 2.0
6+
# which is available at https://www.eclipse.org/legal/epl-2.0/
7+
#
8+
# SPDX-License-Identifier: EPL-2.0
9+
#
10+
11+
# necessary environment variable: PROJECTOR_ASSEMBLY_DIR
12+
if [ -n "$PROJECTOR_ASSEMBLY_DIR" ]; then
13+
cd "$PROJECTOR_ASSEMBLY_DIR"/ide/bin || exit
14+
./ide-projector-launcher.sh
15+
else
16+
echo "Environment variable PROJECTOR_ASSEMBLY_DIR is not set"
17+
fi

static/entrypoint.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ if ! whoami &> /dev/null; then
1616
fi
1717
fi
1818

19-
cd /projector/ide/bin || exit
19+
# PROJECTOR_ASSEMBLY_DIR env variable provided by Docker environment
20+
cd "$PROJECTOR_ASSEMBLY_DIR"/ide/bin || exit
2021

2122
./ide-projector-launcher.sh

static/ide-projector-launcher.sh

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
#
3-
# Copyright (c) 2021 Red Hat, Inc.
3+
# Copyright (c) 2022 Red Hat, Inc.
44
# This program and the accompanying materials are made
55
# available under the terms of the Eclipse Public License 2.0
66
# which is available at https://www.eclipse.org/legal/epl-2.0/
@@ -26,8 +26,9 @@
2626

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

3334
# overwrite default configuration paths for IDE
@@ -121,7 +122,7 @@ sed -i 's+classpath "$CLASSPATH"+classpath "$CLASSPATH:$IDE_HOME/projector-serve
121122
# -Dorg.jetbrains.projector.server.classToLaunch=com.intellij.idea.Main org.jetbrains.projector.server.ProjectorLauncher
122123
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"
123124

124-
bash "$IDE_RUN_FILE_NAME-projector.sh"
125+
bash "$IDE_RUN_FILE_NAME-projector.sh" "nosplash"
125126

126127
rm "$IDE_RUN_FILE_NAME-projector.sh"
127128

0 commit comments

Comments
 (0)