From 013807b043c133a14964266c7a45b958fd4b4f93 Mon Sep 17 00:00:00 2001 From: gattytto Date: Mon, 1 Mar 2021 11:35:50 -0300 Subject: [PATCH] add plantUML sidecar (#863) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add plantUML sidecar Signed-off-by: Esteban Mañaricua * remove unused debs Signed-off-by: Esteban Mañaricua * fix dates Signed-off-by: Esteban Mañaricua --- sidecars/plantuml/Dockerfile | 30 ++++++++++++++++++++++++++++ sidecars/plantuml/PLATFORMS | 1 + sidecars/plantuml/etc/entrypoint.sh | 31 +++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+) create mode 100644 sidecars/plantuml/Dockerfile create mode 100644 sidecars/plantuml/PLATFORMS create mode 100755 sidecars/plantuml/etc/entrypoint.sh diff --git a/sidecars/plantuml/Dockerfile b/sidecars/plantuml/Dockerfile new file mode 100644 index 000000000..0df203870 --- /dev/null +++ b/sidecars/plantuml/Dockerfile @@ -0,0 +1,30 @@ +# Copyright (c) 2021 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 plantuml/plantuml-server + +ENV TMPDIR=/tmp +ENV HOME=/home/theia + +USER root + +RUN mkdir /projects && mkdir -p /home/theia && \ + # Change permissions to let any arbitrary user + for f in "${HOME}" "/etc/passwd" "/projects"; do \ + echo "Changing permissions on ${f}" && chgrp -R 0 ${f} && \ + chmod -R g+rwX ${f}; \ + done && \ + chgrp -R 0 /run && chmod -R g+rwX /run && \ + chgrp -R 0 /var/lib/jetty && chmod -R g+rwX /var/lib/jetty && \ + apt update && apt install -y graphviz + +ADD etc/entrypoint.sh /entrypoint.sh +ENTRYPOINT [ "/entrypoint.sh" ] + +CMD ${PLUGIN_REMOTE_ENDPOINT_EXECUTABLE} diff --git a/sidecars/plantuml/PLATFORMS b/sidecars/plantuml/PLATFORMS new file mode 100644 index 000000000..303dc7a5a --- /dev/null +++ b/sidecars/plantuml/PLATFORMS @@ -0,0 +1 @@ +linux/amd64 diff --git a/sidecars/plantuml/etc/entrypoint.sh b/sidecars/plantuml/etc/entrypoint.sh new file mode 100755 index 000000000..e5db64160 --- /dev/null +++ b/sidecars/plantuml/etc/entrypoint.sh @@ -0,0 +1,31 @@ +#!/bin/sh +# +# Copyright (c) 2018-2021 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 +# + +set -e +set -x + +USER_ID=$(id -u) +export USER_ID +GROUP_ID=$(id -g) +export GROUP_ID + +if ! whoami >/dev/null 2>&1; then + echo "${USER_NAME:-user}:x:${USER_ID}:0:${USER_NAME:-user} user:${HOME}:/bin/sh" >> /etc/passwd +fi + +# Grant access to projects volume in case of non root user with sudo rights +if [ "${USER_ID}" -ne 0 ] && command -v sudo >/dev/null 2>&1 && sudo -n true > /dev/null 2>&1; then + sudo chown "${USER_ID}:${GROUP_ID}" /projects +fi + +exec "$@"