Skip to content

Commit 1f48df7

Browse files
joperezrMichaelSimons
authored andcommitted
PR feedback
1 parent a3a8119 commit 1f48df7

File tree

3 files changed

+45
-36
lines changed

3 files changed

+45
-36
lines changed

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
setup-Alpine.sh eol=lf

src/alpine/3.6-ForHelix/Dockerfile

+9-36
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
FROM alpine:3.6
22

3+
COPY ./setup-Alpine.sh /home/src/setup-Alpine.sh
4+
RUN chmod a+x /home/src/setup-Alpine.sh
5+
36
RUN apk update
47

58
RUN apk add --no-cache \
@@ -30,6 +33,7 @@ RUN apk add --no-cache \
3033
python-dev \
3134
sudo \
3235
util-linux-dev \
36+
wget \
3337
zlib-dev
3438

3539
RUN apk -X https://dl-cdn.alpinelinux.org/alpine/edge/main add --no-cache \
@@ -42,8 +46,8 @@ RUN apk -X https://dl-cdn.alpinelinux.org/alpine/edge/testing add --no-cache \
4246
RUN /usr/sbin/adduser -D -G adm -s /bin/sh helixbot
4347

4448
# Restore pip and set environment
45-
ADD https://bootstrap.pypa.io/get-pip.py /home/helixbot/get-pip.py
46-
RUN /usr/bin/python /home/helixbot/get-pip.py
49+
RUN wget -O /home/helixbot/get-pip.py https://bootstrap.pypa.io/get-pip.py && \
50+
/usr/bin/python /home/helixbot/get-pip.py
4751
ENV pkgmgr apk
4852
ENV HELIX_SCRIPT_ROOT /home/helixbot/dotnetbuild/scripts
4953
ENV HELIX_WORK_ROOT /home/helixbot/dotnetbuild/work
@@ -53,37 +57,6 @@ ENV PYTHONPATH /usr/bin/python:/home/helixbot/dotnetbuild/scripts
5357
ENV HELIX_PYTHONPATH /usr/bin/python
5458
WORKDIR /home/helixbot/
5559

56-
# Write and run script that generates starttestrunner.sh
57-
RUN mkdir /home/src/
58-
RUN echo -e "#!/bin/bash \n\
59-
user_name=helixbot \n\
60-
rootdir=/home/\$user_name \n\
61-
script_root=\$rootdir/dotnetbuild/scripts \n\
62-
work_root=\$rootdir/dotnetbuild/work \n\
63-
log_root=\$rootdir/dotnetbuild/logs \n\
64-
config_root=\$rootdir/dotnetbuild/config \n\
65-
python_path=/usr/bin/python \n\
66-
mkdir -p \$script_root \n\
67-
mkdir -p \$work_root \n\
68-
mkdir -p \$log_root \n\
69-
mkdir -p \$config_root \n\
70-
chown \$user_name \$script_root \n\
71-
chown \$user_name \$work_root \n\
72-
chown \$user_name \$log_root \n\
73-
chown \$user_name \$config_root \n\
74-
chown \$user_name /home/helixbot/get-pip.py \n\
75-
echo \"fs.inotify.max_user_instances=1024\" >> /etc/sysctl.conf \n\
76-
echo cd \\\$HELIX_SCRIPT_ROOT >> /home/\$user_name/starttestrunner.sh \n\
77-
# LANG will be un-set on some Linux OSes, leading to inability to unzip files with unicode content \n\
78-
echo export LANG=en_US.UTF-8 >> /home/\$user_name/starttestrunner.sh \n\
79-
echo sudo -H -u \$user_name \\\$HELIX_PYTHONPATH /home/\$user_name/get-pip.py --user >> /home/\$user_name/starttestrunner.sh \n\
80-
echo sudo -H -u \$user_name \\\$HELIX_PYTHONPATH -m pip install -r \$rootdir/dotnetbuild/scripts/runtime_python_requirements.txt --user >> /home/\$user_name/starttestrunner.sh \n\
81-
echo \"\\\$HELIX_PYTHONPATH start_helix.py | tee -a \\\$HELIX_LOG_ROOT/test_runner.log\" >> /home/\$user_name/starttestrunner.sh \n\
82-
echo \"\\\$HELIX_PYTHONPATH -c \\\"from helix.platformutil import reboot_machine; reboot_machine()\\\" \" >> /home/\$user_name/starttestrunner.sh \n\
83-
chmod 755 /home/\$user_name/starttestrunner.sh \n\
84-
# comment out the line in the /etc/sudoers file if present that requires tty to sudo. \n\
85-
sed -i -e \"s/Defaults.*requiretty.*/#Defaults requiretty/g\" /etc/sudoers \n\
86-
# For now, we will let DotNetBot sudo whatever it wants. \n\
87-
echo \"\$user_name ALL=(ALL) NOPASSWD: ALL\" | (EDITOR=\"tee -a\" visudo)" > /home/src/setup-Alpine.sh
88-
89-
RUN /bin/sh /home/src/setup-Alpine.sh
60+
# Run script that generates starttestrunner.sh
61+
RUN /home/src/setup-Alpine.sh
62+
USER helixbot
+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash
2+
3+
# Set environment
4+
user_name=helixbot
5+
rootdir=/home/$user_name
6+
script_root=$rootdir/dotnetbuild/scripts
7+
work_root=$rootdir/dotnetbuild/work
8+
log_root=$rootdir/dotnetbuild/logs
9+
config_root=$rootdir/dotnetbuild/config
10+
python_path=/usr/bin/python
11+
12+
#Create directories if they don't exist
13+
mkdir -p $script_root
14+
mkdir -p $work_root
15+
mkdir -p $log_root
16+
mkdir -p $config_root
17+
chown $user_name $script_root
18+
chown $user_name $work_root
19+
chown $user_name $log_root
20+
chown $user_name $config_root
21+
chown $user_name /home/helixbot/get-pip.py
22+
23+
# Allow multiple instances and write starttestrunner.sh
24+
echo "fs.inotify.max_user_instances=1024" >> /etc/sysctl.conf
25+
echo cd \$HELIX_SCRIPT_ROOT >> /home/$user_name/starttestrunner.sh
26+
echo export LANG=en_US.UTF-8 >> /home/$user_name/starttestrunner.sh
27+
echo sudo -H -u $user_name \$HELIX_PYTHONPATH /home/$user_name/get-pip.py --user >> /home/$user_name/starttestrunner.sh
28+
echo sudo -H -u $user_name \$HELIX_PYTHONPATH -m pip install -r $rootdir/dotnetbuild/scripts/runtime_python_requirements.txt --user >> /home/$user_name/starttestrunner.sh
29+
echo "\$HELIX_PYTHONPATH start_helix.py | tee -a \$HELIX_LOG_ROOT/test_runner.log" >> /home/$user_name/starttestrunner.sh
30+
echo "\$HELIX_PYTHONPATH -c \"from helix.platformutil import reboot_machine; reboot_machine()\" " >> /home/$user_name/starttestrunner.sh
31+
chmod 755 /home/$user_name/starttestrunner.sh
32+
33+
# Give permissions to helixbot
34+
sed -i -e "s/Defaults.*requiretty.*/#Defaults requiretty/g" /etc/sudoers
35+
echo "$user_name ALL=(ALL) NOPASSWD: ALL" | (EDITOR="tee -a" visudo)

0 commit comments

Comments
 (0)