This repository has been archived by the owner on Oct 18, 2024. It is now read-only.
forked from eclipse-che/che-theia
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'pr-fix-failures-on-non-root' into prp-fix-failures-on-n…
…on-root
- Loading branch information
Showing
14 changed files
with
157 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,7 +54,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ | |
|
||
# Install [email protected] and node-gyp | ||
|
||
&& yarn global add [email protected] node-gyp | ||
&& yarn global add [email protected] node-gyp \ | ||
&& node-gyp install | ||
|
||
ENV HOME=/home/theia | ||
COPY --from=endpoint /home/theia /home/theia | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,15 @@ | |
# | ||
FROM node:10.15-alpine | ||
|
||
# Add npm global bin directory to the path | ||
ENV HOME=/home/theia-dev \ | ||
PATH=/home/theia-dev/.npm-global/bin:${PATH} \ | ||
# Specify the directory of git (avoid to search at init of Theia) | ||
USE_LOCAL_GIT=true \ | ||
LOCAL_GIT_DIRECTORY=/usr \ | ||
GIT_EXEC_PATH=/usr/libexec/git-core \ | ||
THEIA_ELECTRON_SKIP_REPLACE_FFMPEG=true | ||
|
||
RUN apk add --update --no-cache \ | ||
# Download some files | ||
curl \ | ||
|
@@ -26,17 +35,15 @@ RUN apk add --update --no-cache \ | |
less \ | ||
# bash shell | ||
bash \ | ||
# give root privilege | ||
sudo \ | ||
# for useradd command | ||
shadow \ | ||
# some lib to compile 'native-keymap' npm mpdule | ||
libx11-dev libxkbfile-dev | ||
|
||
# Add npm global bin directory to the path | ||
ENV HOME=/home/theia-dev \ | ||
PATH=/home/theia-dev/.npm-global/bin:${PATH} \ | ||
# Specify the directory of git (avoid to search at init of Theia) | ||
USE_LOCAL_GIT=true \ | ||
LOCAL_GIT_DIRECTORY=/usr \ | ||
GIT_EXEC_PATH=/usr/libexec/git-core \ | ||
THEIA_ELECTRON_SKIP_REPLACE_FFMPEG=true | ||
libx11-dev libxkbfile-dev && \ | ||
useradd -u 1001 -U -G root -d ${HOME} -s /bin/bash theia-dev && \ | ||
apk del --no-cache shadow && \ | ||
echo "%root ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers | ||
|
||
# Define package of the theia generator to use | ||
ARG THEIA_GENERATOR_PACKAGE=@eclipse-che/[email protected] | ||
|
@@ -49,25 +56,25 @@ EXPOSE 3000 3030 | |
# Configure npm and yarn to use home folder for global dependencies | ||
RUN npm config set prefix "${HOME}/.npm-global" && \ | ||
echo "--global-folder \"${HOME}/.yarn-global\"" > ${HOME}/.yarnrc && \ | ||
# Setup node-gyp. Yarn will be failed unless installing required files here. | ||
yarn global add node-gyp && node-gyp install && \ | ||
# add eclipse che theia generator | ||
yarn global add yo @theia/[email protected] ${THEIA_GENERATOR_PACKAGE} && \ | ||
# Generate .passwd.template \ | ||
cat /etc/passwd | \ | ||
sed s#root:x.*#theia-dev:x:\${USER_ID}:\${GROUP_ID}::${HOME}:/bin/bash#g \ | ||
> ${HOME}/.passwd.template && \ | ||
# Generate .group.template \ | ||
cat /etc/group | \ | ||
sed s#root:x:0:#root:x:0:0,\${USER_ID}:#g \ | ||
> ${HOME}/.group.template && \ | ||
sed -e "s#^theia-dev:x.*#theia-dev:x:\${USER_ID}:\${GROUP_ID}::${HOME}:/bin/bash#g" \ | ||
/etc/passwd > ${HOME}/.passwd.template && \ | ||
sed -e 's#^theia-dev:.*#theia-dev:x:${GROUP_ID}:#g' \ | ||
/etc/group > ${HOME}/.group.template && \ | ||
mkdir /projects && \ | ||
# Define default prompt | ||
echo "export PS1='\[\033[01;33m\](\u@container)\[\033[01;36m\] (\w) \$ \[\033[00m\]'" > ${HOME}/.bashrc && \ | ||
# Disable the statistics for yeoman | ||
mkdir -p ${HOME}/.config/insight-nodejs/ && \ | ||
echo '{"optOut": true}' > ${HOME}/.config/insight-nodejs/insight-yo.json && \ | ||
# Change permissions to let any arbitrary user | ||
for f in "${HOME}" "/etc/passwd" "/etc/group" "/projects"; do \ | ||
echo "Changing permissions on ${f}" && chgrp -R 0 ${f} && \ | ||
for f in "${HOME}" /projects /etc/passwd /etc/group; do \ | ||
echo "Changing permissions on ${f}" && \ | ||
chgrp -R 0 ${f} && \ | ||
chmod -R g+rwX ${f}; \ | ||
done | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/sh | ||
|
||
. /entrypoint.sh | ||
|
||
cd /projects | ||
|
||
# Just try to build the latest theia with current image | ||
git clone -b 'master' --single-branch --depth 1 https://github.com/theia-ide/theia theia | ||
cd theia && yarn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/bin/sh | ||
# Copyright (c) 2018 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 | ||
|
||
base_dir=$(cd "$(dirname "$0")"; pwd) | ||
. "${base_dir}/../../build.include" | ||
|
||
init --name:theia-builder-e2e "$@" | ||
|
||
DOCKER_RUN_OPTIONS="" | ||
# run bats with terminal mode (pretty print) if supported by current shell | ||
if [ -t 1 ]; then | ||
DOCKER_RUN_OPTIONS="-t" | ||
fi | ||
|
||
# Runs E2E tests in a docker container. | ||
run_test_in_docker_container() { | ||
docker_exec run --rm ${DOCKER_RUN_OPTIONS} \ | ||
--user $1 --group-add 0 \ | ||
$IMAGE_NAME | ||
} | ||
|
||
run_test_in_docker_container 0:0 | ||
run_test_in_docker_container 1234:5678 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,7 +72,7 @@ RUN che:theia init -c ${HOME}/che-theia-init-sources.yml | |
RUN che:theia cdn --theia="${CDN_PREFIX}" --monaco="${MONACO_CDN_PREFIX}" | ||
|
||
# Compile Theia | ||
RUN yarn | ||
RUN yarn global add node-gyp && node-gyp install && yarn | ||
|
||
# Run into production mode | ||
RUN che:theia production | ||
|
@@ -112,25 +112,22 @@ COPY --from=builder /home/theia-dev/theia-source-code/production/plugins /defaul | |
# Install curl and bash | ||
# Install ssh for cloning ssh-repositories | ||
# Install less for handling git diff properly | ||
RUN apk add --update --no-cache sudo git bzip2 which bash curl openssh openssh-keygen less | ||
RUN adduser -D -S -u 1001 -G root -h ${HOME} -s /bin/sh theia \ | ||
&& echo "%wheel ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers \ | ||
# Create /projects for Che | ||
&& mkdir /projects \ | ||
# Create root node_modules in order to not use node_modules in each project folder | ||
&& mkdir /node_modules \ | ||
RUN apk add --update --no-cache sudo git bzip2 which bash curl openssh openssh-keygen less shadow \ | ||
&& useradd -u 1001 -U -G root -d ${HOME} -s /bin/bash theia-dev \ | ||
&& apk del --no-cache shadow \ | ||
&& echo "%root ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers | ||
|
||
RUN mkdir /projects /node_modules \ | ||
# 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 \ | ||
&& 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}; \ | ||
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 \ | ||
# For non-root instances. File permissions will be fixed in `entrypoint.sh`. | ||
&& sed -e 's#theia:x.*#theia:x:\${USER_ID}:\${GROUP_ID}::\${HOME}:/bin/bash#g' \ | ||
/etc/passwd > ${HOME}/.passwd.template \ | ||
&& sed -e 's#^theia:.*#theia:x:${GROUP_ID}:#g' \ | ||
/etc/group > ${HOME}/.group.template \ | ||
# Add yeoman, theia plugin generator and typescript (to have tsc/typescript working) | ||
&& yarn global add yo @theia/[email protected] [email protected] \ | ||
&& mkdir -p ${HOME}/.config/insight-nodejs/ \ | ||
&& chmod -R 777 ${HOME}/.config/ \ | ||
# Disable the statistics for yeoman | ||
&& echo '{"optOut": true}' > $HOME/.config/insight-nodejs/insight-yo.json \ | ||
# Link yarn global modules for yeoman | ||
|
@@ -140,9 +137,13 @@ RUN adduser -D -S -u 1001 -G root -h ${HOME} -s /bin/sh theia \ | |
# Cleanup yarn cache | ||
&& yarn cache clean \ | ||
# Change permissions to allow editing of files for openshift user | ||
&& find ${HOME} -exec sh -c "chgrp 0 {}; chmod g+rwX {}" \; | ||
&& 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}; \ | ||
done | ||
|
||
COPY --chown=theia:root --from=builder /home/theia-dev/theia-source-code/production /home/theia | ||
|
||
USER theia | ||
WORKDIR /projects | ||
ADD src/entrypoint.sh /entrypoint.sh | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,22 +10,23 @@ FROM ${BUILD_ORGANIZATION}/${BUILD_PARENT_IMAGE}:${BUILD_TAG} as theia | |
FROM cypress/browsers:chrome67 | ||
|
||
USER root | ||
ENV HOME=/root | ||
ENV NOCDN=true | ||
|
||
RUN printf "deb http://archive.debian.org/debian/ jessie main\ndeb-src http://archive.debian.org/debian/ jessie main\ndeb http://security.debian.org jessie/updates main\ndeb-src http://security.debian.org jessie/updates main" > /etc/apt/sources.list | ||
RUN apt-get update && \ | ||
apt-get install -y libx11-dev libxkbfile-dev sudo iproute2 | ||
CMD /root/docker-run.sh | ||
RUN yarn global add [email protected] node-gyp | ||
RUN yarn global add [email protected] node-gyp && node-gyp install | ||
|
||
# Add cypress scripts and grab dependencies | ||
COPY src /root/ | ||
RUN cd /root && yarn | ||
COPY src /projects/ | ||
RUN cd /projects && yarn | ||
|
||
# Add tests | ||
ADD cypress /root/cypress/ | ||
ADD cypress /projects/cypress/ | ||
|
||
COPY --from=theia /home/theia /home/theia | ||
COPY --from=theia /entrypoint.sh /entrypoint.sh | ||
RUN find /home/theia/ -name "binding.gyp" | xargs -i sh -c 'cd $(dirname {}) && node-gyp rebuild' | ||
|
||
USER theia | ||
CMD /projects/docker-run.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.