From 2662e5882805647c2dd7de3645d04a3b9682318e Mon Sep 17 00:00:00 2001 From: Anatoliy Bazko Date: Fri, 6 Sep 2019 12:53:19 +0300 Subject: [PATCH 1/3] Generate settings.xml Signed-off-by: Anatoliy Bazko --- .../theia-endpoint-runtime/etc/entrypoint.sh | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/dockerfiles/theia-endpoint-runtime/etc/entrypoint.sh b/dockerfiles/theia-endpoint-runtime/etc/entrypoint.sh index 1f85f5768..bcbbf3ade 100755 --- a/dockerfiles/theia-endpoint-runtime/etc/entrypoint.sh +++ b/dockerfiles/theia-endpoint-runtime/etc/entrypoint.sh @@ -11,6 +11,35 @@ # Red Hat, Inc. - initial API and implementation # +set_maven_mirror() { + local m2="$HOME"/.m2 + local settingsXML="$m2"/settings.xml + + [ ! -d "$m2" ] && mkdir -p "$m2" + + if [ ! -f "$settingsXML" ]; then + echo "> "$settingsXML" + echo " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" >> "$settingsXML" + echo " xsi:schemaLocation=\"http://maven.apache.org/SETTINGS/1.0.0" >> "$settingsXML" + echo " https://maven.apache.org/xsd/settings-1.0.0.xsd\">" >> "$settingsXML" + echo " " >> "$settingsXML" + echo " " >> "$settingsXML" + echo " \${env.MAVEN_MIRROR_URL}" >> "$settingsXML" + echo " external:*" >> "$settingsXML" + echo " " >> "$settingsXML" + echo " " >> "$settingsXML" + echo "" >> "$settingsXML" + else + if ! grep -q "\${env.MAVEN_MIRROR_URL}" "$settingsXML"; then + if grep -q "" "$settingsXML"; then + sed -i 's//\n \n ${env.MAVEN_MIRROR_URL}<\/url>\n external:\*<\/mirrorOf>\n <\/mirror>/' "$settingsXML" + else + sed -i 's/<\/settings>/ \n \n ${env.MAVEN_MIRROR_URL}<\/url>\n external:*<\/mirrorOf>\n <\/mirror>\n <\/mirrors>\n<\/settings>/' "$settingsXML" + fi + fi + fi +} + export USER_ID=$(id -u) export GROUP_ID=$(id -g) @@ -51,6 +80,9 @@ trap 'responsible_shutdown' SIGHUP SIGTERM SIGINT cd ${HOME} +# generate settings.xml if needed +[ ! -z "$MAVEN_MIRROR_URL" ] && set_maven_mirror + # run theia endpoint node /home/theia/lib/node/plugin-remote.js & From a636571ccc62b72f9e9668c378f53bb710091d81 Mon Sep 17 00:00:00 2001 From: Anatoliy Bazko Date: Tue, 10 Sep 2019 11:16:10 +0300 Subject: [PATCH 2/3] fix Signed-off-by: Anatoliy Bazko --- dockerfiles/remote-plugin-java11/Dockerfile | 1 + .../remote-plugin-java11/etc/before-start.sh | 44 +++++++++++++++++++ dockerfiles/remote-plugin-java8/Dockerfile | 1 + .../remote-plugin-java8/etc/before-start.sh | 43 ++++++++++++++++++ .../theia-endpoint-runtime/etc/entrypoint.sh | 32 +------------- 5 files changed, 90 insertions(+), 31 deletions(-) create mode 100755 dockerfiles/remote-plugin-java11/etc/before-start.sh create mode 100755 dockerfiles/remote-plugin-java8/etc/before-start.sh diff --git a/dockerfiles/remote-plugin-java11/Dockerfile b/dockerfiles/remote-plugin-java11/Dockerfile index 7d7434985..8e2ce47c8 100644 --- a/dockerfiles/remote-plugin-java11/Dockerfile +++ b/dockerfiles/remote-plugin-java11/Dockerfile @@ -13,4 +13,5 @@ RUN apk --no-cache add openjdk11 --repository=http://dl-cdn.alpinelinux.org/alpi && apk add procps nss \ && chmod 777 /home/theia ENV JAVA_HOME /usr/lib/jvm/default-jvm/ +ADD etc/before-start.sh /before-start.sh WORKDIR /projects diff --git a/dockerfiles/remote-plugin-java11/etc/before-start.sh b/dockerfiles/remote-plugin-java11/etc/before-start.sh new file mode 100755 index 000000000..356bcaca1 --- /dev/null +++ b/dockerfiles/remote-plugin-java11/etc/before-start.sh @@ -0,0 +1,44 @@ +#!/bin/sh +# +# Copyright (c) 2018-2019 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_maven_mirror() { + local m2="$HOME"/.m2 + local settingsXML="$m2"/settings.xml + + [ ! -d "$m2" ] && mkdir -p "$m2" + + if [ ! -f "$settingsXML" ]; then + echo "> "$settingsXML" + echo " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" >> "$settingsXML" + echo " xsi:schemaLocation=\"http://maven.apache.org/SETTINGS/1.0.0" >> "$settingsXML" + echo " https://maven.apache.org/xsd/settings-1.0.0.xsd\">" >> "$settingsXML" + echo " " >> "$settingsXML" + echo " " >> "$settingsXML" + echo " \${env.MAVEN_MIRROR_URL}" >> "$settingsXML" + echo " external:*" >> "$settingsXML" + echo " " >> "$settingsXML" + echo " " >> "$settingsXML" + echo "" >> "$settingsXML" + else + if ! grep -q "\${env.MAVEN_MIRROR_URL}" "$settingsXML"; then + if grep -q "" "$settingsXML"; then + sed -i 's//\n \n ${env.MAVEN_MIRROR_URL}<\/url>\n external:\*<\/mirrorOf>\n <\/mirror>/' "$settingsXML" + else + sed -i 's/<\/settings>/ \n \n ${env.MAVEN_MIRROR_URL}<\/url>\n external:*<\/mirrorOf>\n <\/mirror>\n <\/mirrors>\n<\/settings>/' "$settingsXML" + fi + fi + fi +} + +[ ! -z "$MAVEN_MIRROR_URL" ] && set_maven_mirror +return 0 diff --git a/dockerfiles/remote-plugin-java8/Dockerfile b/dockerfiles/remote-plugin-java8/Dockerfile index 763488c2e..f64b61766 100644 --- a/dockerfiles/remote-plugin-java8/Dockerfile +++ b/dockerfiles/remote-plugin-java8/Dockerfile @@ -11,4 +11,5 @@ FROM ${BUILD_ORGANIZATION}/${BUILD_PREFIX}-theia-endpoint-runtime:${BUILD_TAG} RUN apk --update --no-cache add openjdk8 procps nss ENV JAVA_HOME /usr/lib/jvm/default-jvm/ +ADD etc/before-start.sh /before-start.sh WORKDIR /projects diff --git a/dockerfiles/remote-plugin-java8/etc/before-start.sh b/dockerfiles/remote-plugin-java8/etc/before-start.sh new file mode 100755 index 000000000..b38982620 --- /dev/null +++ b/dockerfiles/remote-plugin-java8/etc/before-start.sh @@ -0,0 +1,43 @@ +#!/bin/sh +# +# Copyright (c) 2018-2019 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_maven_mirror() { + local m2="$HOME"/.m2 + local settingsXML="$m2"/settings.xml + + [ ! -d "$m2" ] && mkdir -p "$m2" + + if [ ! -f "$settingsXML" ]; then + echo "> "$settingsXML" + echo " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" >> "$settingsXML" + echo " xsi:schemaLocation=\"http://maven.apache.org/SETTINGS/1.0.0" >> "$settingsXML" + echo " https://maven.apache.org/xsd/settings-1.0.0.xsd\">" >> "$settingsXML" + echo " " >> "$settingsXML" + echo " " >> "$settingsXML" + echo " \${env.MAVEN_MIRROR_URL}" >> "$settingsXML" + echo " external:*" >> "$settingsXML" + echo " " >> "$settingsXML" + echo " " >> "$settingsXML" + echo "" >> "$settingsXML" + else + if ! grep -q "\${env.MAVEN_MIRROR_URL}" "$settingsXML"; then + if grep -q "" "$settingsXML"; then + sed -i 's//\n \n ${env.MAVEN_MIRROR_URL}<\/url>\n external:\*<\/mirrorOf>\n <\/mirror>/' "$settingsXML" + else + sed -i 's/<\/settings>/ \n \n ${env.MAVEN_MIRROR_URL}<\/url>\n external:*<\/mirrorOf>\n <\/mirror>\n <\/mirrors>\n<\/settings>/' "$settingsXML" + fi + fi + fi +} + +[ ! -z "$MAVEN_MIRROR_URL" ] && set_maven_mirror +return 0 diff --git a/dockerfiles/theia-endpoint-runtime/etc/entrypoint.sh b/dockerfiles/theia-endpoint-runtime/etc/entrypoint.sh index bcbbf3ade..525355a37 100755 --- a/dockerfiles/theia-endpoint-runtime/etc/entrypoint.sh +++ b/dockerfiles/theia-endpoint-runtime/etc/entrypoint.sh @@ -11,35 +11,6 @@ # Red Hat, Inc. - initial API and implementation # -set_maven_mirror() { - local m2="$HOME"/.m2 - local settingsXML="$m2"/settings.xml - - [ ! -d "$m2" ] && mkdir -p "$m2" - - if [ ! -f "$settingsXML" ]; then - echo "> "$settingsXML" - echo " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" >> "$settingsXML" - echo " xsi:schemaLocation=\"http://maven.apache.org/SETTINGS/1.0.0" >> "$settingsXML" - echo " https://maven.apache.org/xsd/settings-1.0.0.xsd\">" >> "$settingsXML" - echo " " >> "$settingsXML" - echo " " >> "$settingsXML" - echo " \${env.MAVEN_MIRROR_URL}" >> "$settingsXML" - echo " external:*" >> "$settingsXML" - echo " " >> "$settingsXML" - echo " " >> "$settingsXML" - echo "" >> "$settingsXML" - else - if ! grep -q "\${env.MAVEN_MIRROR_URL}" "$settingsXML"; then - if grep -q "" "$settingsXML"; then - sed -i 's//\n \n ${env.MAVEN_MIRROR_URL}<\/url>\n external:\*<\/mirrorOf>\n <\/mirror>/' "$settingsXML" - else - sed -i 's/<\/settings>/ \n \n ${env.MAVEN_MIRROR_URL}<\/url>\n external:*<\/mirrorOf>\n <\/mirror>\n <\/mirrors>\n<\/settings>/' "$settingsXML" - fi - fi - fi -} - export USER_ID=$(id -u) export GROUP_ID=$(id -g) @@ -80,8 +51,7 @@ trap 'responsible_shutdown' SIGHUP SIGTERM SIGINT cd ${HOME} -# generate settings.xml if needed -[ ! -z "$MAVEN_MIRROR_URL" ] && set_maven_mirror +[ -f "/before-start.sh" ] && . "/before-start.sh" # run theia endpoint node /home/theia/lib/node/plugin-remote.js & From cb9a97bf4496d185126be9bd08e516b5d76a0a2a Mon Sep 17 00:00:00 2001 From: Anatoliy Bazko Date: Tue, 10 Sep 2019 15:47:25 +0300 Subject: [PATCH 3/3] fix Signed-off-by: Anatoliy Bazko --- dockerfiles/remote-plugin-java11/etc/before-start.sh | 2 +- dockerfiles/remote-plugin-java8/etc/before-start.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dockerfiles/remote-plugin-java11/etc/before-start.sh b/dockerfiles/remote-plugin-java11/etc/before-start.sh index 356bcaca1..d2f3b0ad4 100755 --- a/dockerfiles/remote-plugin-java11/etc/before-start.sh +++ b/dockerfiles/remote-plugin-java11/etc/before-start.sh @@ -1,6 +1,6 @@ #!/bin/sh # -# Copyright (c) 2018-2019 Red Hat, Inc. +# Copyright (c) 2019 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/ diff --git a/dockerfiles/remote-plugin-java8/etc/before-start.sh b/dockerfiles/remote-plugin-java8/etc/before-start.sh index b38982620..db000d8ea 100755 --- a/dockerfiles/remote-plugin-java8/etc/before-start.sh +++ b/dockerfiles/remote-plugin-java8/etc/before-start.sh @@ -1,6 +1,6 @@ #!/bin/sh # -# Copyright (c) 2018-2019 Red Hat, Inc. +# Copyright (c) 2019 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/