Skip to content
This repository was archived by the owner on Oct 18, 2024. It is now read-only.

Commit c455e06

Browse files
committed
Add tests for non-root environments.
Signed-off-by: Masaki Muranaka <monaka@monami-ya.com>
1 parent d984417 commit c455e06

File tree

3 files changed

+16
-12
lines changed

3 files changed

+16
-12
lines changed

dockerfiles/theia/e2e/Dockerfile

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,23 @@ FROM ${BUILD_ORGANIZATION}/${BUILD_PARENT_IMAGE}:${BUILD_TAG} as theia
1010
FROM cypress/browsers:chrome67
1111

1212
USER root
13-
ENV HOME=/root
1413
ENV NOCDN=true
1514

1615
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
1716
RUN apt-get update && \
1817
apt-get install -y libx11-dev libxkbfile-dev sudo iproute2
19-
CMD /root/docker-run.sh
2018
RUN yarn global add typescript@2.9.2 node-gyp && node-gyp install
2119

2220
# Add cypress scripts and grab dependencies
23-
COPY src /root/
24-
RUN cd /root && yarn
21+
COPY src /projects/
22+
RUN cd /projects && yarn
2523

2624
# Add tests
27-
ADD cypress /root/cypress/
25+
ADD cypress /projects/cypress/
2826

2927
COPY --from=theia /home/theia /home/theia
3028
COPY --from=theia /entrypoint.sh /entrypoint.sh
3129
RUN find /home/theia/ -name "binding.gyp" | xargs -i sh -c 'cd $(dirname {}) && node-gyp rebuild --ensure'
30+
31+
USER theia
32+
CMD /projects/docker-run.sh

dockerfiles/theia/e2e/src/docker-run.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010
: "${WAIT_COUNT:=30}"
1111

1212
echo "Starting Theia..."
13-
rm -rf /root/logs/*
14-
HOME=/home/theia /entrypoint.sh > /root/logs/theia.log 2>/root/logs/theia-error.log&
13+
rm -rf /projects/logs/*
14+
HOME=/home/theia /entrypoint.sh > /projects/logs/theia.log 2>/projects/logs/theia-error.log&
1515

1616
echo "Cleaning videos folder..."
1717
# Cleanup previous videos
18-
rm -rf /root/cypress/videos/*
18+
rm -rf /projects/cypress/videos/*
1919

2020
# Find TCP 0.0.0.0:3100 that will be opened by Theia.
2121
sleep 5s
@@ -35,4 +35,4 @@ fi
3535

3636
# Run tests
3737
echo "Run the tests"
38-
cd /root && unset LD_LIBRARY_PATH && /root/node_modules/.bin/cypress run -c trashAssetsBeforeRuns=false --browser chrome
38+
cd /projects && unset LD_LIBRARY_PATH && /projects/node_modules/.bin/cypress run -c trashAssetsBeforeRuns=false --browser chrome

dockerfiles/theia/e2e/test.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,14 @@ fi
1919

2020
# Runs E2E tests in a docker container.
2121
run_test_in_docker_container() {
22+
mkdir -p ${base_dir}/$1
2223
docker_exec run --rm ${DOCKER_RUN_OPTIONS} \
23-
-v "${base_dir}/videos":/root/cypress/videos \
24-
-v "${base_dir}/logs":/root/logs \
24+
--user $1 \
25+
-v "${base_dir}/$1/videos":/projects/cypress/videos \
26+
-v "${base_dir}/$1/logs":/projects/logs \
2527
-v /var/run/docker.sock:/var/run/docker.sock \
2628
$IMAGE_NAME
2729
}
2830

29-
run_test_in_docker_container
31+
run_test_in_docker_container '0:0'
32+
run_test_in_docker_container '1234:5678'

0 commit comments

Comments
 (0)