From 1369f39733526a316c8ba0fbcb6d0e18c5964766 Mon Sep 17 00:00:00 2001 From: Sun Seng David TAN Date: Thu, 31 Jan 2019 12:47:41 +0000 Subject: [PATCH] Build plugins from che-theia-dev builder image rather than getting it from released travis Signed-off-by: Sun Seng David TAN --- dockerfiles/theia/Dockerfile | 49 ++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/dockerfiles/theia/Dockerfile b/dockerfiles/theia/Dockerfile index 4fca13092..775fab214 100644 --- a/dockerfiles/theia/Dockerfile +++ b/dockerfiles/theia/Dockerfile @@ -70,6 +70,49 @@ RUN che:theia production # change permissions RUN find production -exec sh -c "chgrp 0 {}; chmod g+rwX {}" \; 2>log.txt + + + +### +# Plugin Builder Image +# +FROM ${BUILD_ORGANIZATION}/${BUILD_PREFIX}-theia-dev:${BUILD_TAG} as plugins-builder +WORKDIR ${HOME} + +# define in env variable GITHUB_TOKEN only if it is defined +# else check if github rate limit is enough, else will abort requiring to set GITHUB_TOKEN value +ARG GITHUB_TOKEN + +# Define che-theia branch to use for plugins +ARG CHE_THEIA_PLUGIN_BRANCH=master + +# Check github limit +RUN if [ ! -z "${GITHUB_TOKEN-}" ]; then \ + export GITHUB_TOKEN=$GITHUB_TOKEN; \ + echo "Setting GITHUB_TOKEN value as provided"; \ + else \ + export GITHUB_LIMIT=$(curl -s 'https://api.github.com/rate_limit' | jq '.rate .remaining'); \ + echo "Current API rate limit https://api.github.com is ${GITHUB_LIMIT}"; \ + if [ "${GITHUB_LIMIT}" -lt 10 ]; then \ + printf "\033[0;31m\n\n\nRate limit on https://api.github.com is reached so in order to build this image, "; \ + printf "the build argument GITHUB_TOKEN needs to be provided so build will not fail.\n\n\n\033[0m"; \ + exit 1; \ + else \ + echo "GITHUB_TOKEN variable is not set but https://api.github.com rate limit has enough slots"; \ + fi \ + fi + +# Clone and build che-theia plugins +RUN git clone --branch ${CHE_THEIA_PLUGIN_BRANCH} --single-branch --depth 1 https://github.com/eclipse/che-theia ${HOME}/che-theia-source-code +WORKDIR ${HOME}/che-theia-source-code/plugins/containers-plugins +RUN yarn +WORKDIR ${HOME}/che-theia-source-code/plugins/factory-plugin +RUN yarn + +RUN find ${HOME}/che-theia-source-code/plugins/ -name "*.theia" -exec sh -c "chgrp 0 {}; chmod g+rwX {}" \; 2>log.txt + + + ### # Runtime Image # @@ -101,8 +144,6 @@ RUN adduser --disabled-password -S -u 1001 -G root -h ${HOME} -s /bin/sh theia \ && mkdir /default-theia-plugins \ # Download yeoman generator plug-in && curl -L -o /default-theia-plugins/theia_yeoman_plugin.theia https://github.com/eclipse/theia-yeoman-plugin/releases/download/untagged-04f28ee329e479cc465b/theia_yeoman_plugin.theia \ - && curl -L -o /default-theia-plugins/eclipse_che_theia_factory_plugin.theia https://github.com/eclipse/che-theia/releases/download/0.0.1/eclipse_che_theia_factory_plugin.theia \ - && curl -L -o /default-theia-plugins/eclipse_che_theia_containers_plugin.theia https://github.com/eclipse/che-theia/releases/download/0.0.1/eclipse_che_theia_containers_plugin.theia \ && for f in "${HOME}" "/etc/passwd" "/etc/group /node_modules /default-theia-plugins /projects"; do\ sudo chgrp -R 0 ${f} && \ sudo chmod -R g+rwX ${f}; \ @@ -127,6 +168,10 @@ RUN adduser --disabled-password -S -u 1001 -G root -h ${HOME} -s /bin/sh theia \ && find ${HOME} -exec sh -c "chgrp 0 {}; chmod g+rwX {}" \; COPY --chown=theia:root --from=builder /home/theia-dev/theia-source-code/production /home/theia + +COPY --chown=theia:root --from=plugins-builder /home/theia-dev/che-theia-source-code/plugins/factory-plugin/eclipse_che_theia_factory_plugin.theia /default-theia-plugins/eclipse_che_theia_factory_plugin.theia +COPY --chown=theia:root --from=plugins-builder /home/theia-dev/che-theia-source-code/plugins/containers-plugin/eclipse_che_theia_containers_plugin.theia /default-theia-plugins/eclipse_che_theia_containers_plugin.theia + USER theia WORKDIR /projects ADD src/entrypoint.sh /entrypoint.sh