Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal for major changes to (and expansion of) containerised build system #1982

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ansible/inventory.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ hosts:
ubuntu1604-x86-2: {ip: 104.131.191.135}
ubuntu1804_docker-x64-1: {ip: 134.209.55.216}
ubuntu1804_docker-x64-2: {ip: 159.89.183.200}
ubuntu2004_docker-x64-1: {ip: 167.71.99.4}
ubuntu2004_docker-x64-2: {ip: 159.203.120.157}
ubuntu1804-x64-1: {ip: 178.128.181.213}

- ibm:
Expand Down
11 changes: 8 additions & 3 deletions ansible/roles/baselayout/vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ sshd_service_map: {
sshd_service_name: "{{ sshd_service_map[os]|default(sshd_service_map[os|stripversion])|default('sshd') }}"

ntp_service: {
systemd: ['debian8', 'debian9', 'debian10', 'ubuntu1604', 'ubuntu1804'],
systemd: ['debian8', 'debian9', 'debian10', 'ubuntu1604', 'ubuntu1804', 'ubuntu2004'],
ntp_package: ['ubuntu1404']
}

Expand Down Expand Up @@ -143,10 +143,15 @@ packages: {
],

ubuntu: [
'ccache,g++,gcc,g++-6,gcc-6,git,libfontconfig1,sudo,python3-pip',
'ccache,g++,gcc,g++-6,gcc-6,git,libfontconfig1,sudo,python3-pip,python-setuptools,python3-setuptools',
],

ubuntu1404: [
'ntp,gcc-8,g++-8,gcc-6,g++-6,g++-4.8,gcc-4.8,g++-4.9,gcc-4.9,binutils-2.26',
]
],

ubuntu: [
'ccache,g++,gcc,g++,git,libfontconfig1,sudo,python3-pip,python-setuptools,python3-setuptools',
],

}
2 changes: 1 addition & 1 deletion ansible/roles/docker/vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ sshd_service_map: {
sshd_service_name: "{{ sshd_service_map[os]|default(sshd_service_map[os|stripversion])|default('sshd') }}"

ntp_service: {
systemd: ['debian8', 'debian9', 'debian10', 'ubuntu1604', 'ubuntu1804'],
systemd: ['debian8', 'debian9', 'debian10', 'ubuntu1604', 'ubuntu1804', 'ubuntu2004'],
ntp_package: ['ubuntu1404']
}

Expand Down
82 changes: 82 additions & 0 deletions ansible/roles/jenkins-worker/files/docker-node-exec.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#!/bin/bash

## This script is designed to be enabled in /etc/sudoers for the `iojs` user,
## the only privileged access that user has to Docker.
## Since there is considerable access given by selecting arbitrary images and
## execution commands, there are still security concerns and additions of new
## images and changes to existing ones as well as the Bash that's executed
## inside them should be monitored for malicious activity.

set -e

OPTIND=1
image_base="rvagg/node-ci-containers"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably create a user for the Node.js project and use that instead of rvagg right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see your comment elsewhere about the path not being important so seems like you have already acknowledged we should do something on that front.

image_tag=
exec_script="node-ci-exec.sh"

while getopts "i:" opt; do
case "$opt" in
i)
if [[ "$OPTARG" =~ ^[a-zA-Z0-9_-]+$ ]]; then
image_tag=$OPTARG
else
echo "Bad -i value"
exit 1
fi
;;
*)
echo "Wut?"
exit 1
esac
done

if test "$image_tag" = ""; then
echo "Did not provide the docker image [-i]"
exit 1
fi

if [ ! -f "$(pwd)/$exec_script" ]; then
echo "Did not provide a node-ci-exec.sh script"
exit 1
fi

set -x

image="${image_base}:${image_tag}"
# failure to pull is acceptable if Docker Hub is offline or erroring and we have the image
docker pull "${image}" || true
#docker run \
# --init \
# -e TINI_SUBREAPER=true \
# -e TINI_KILL_PROCESS_GROUP=true \
# -e TINI_VERBOSITY=3 \
# --rm \
# -v $(pwd):/home/iojs/workspace \
# -v /home/iojs/.ccache/${image_tag}:/home/iojs/.ccache \
# -u iojs \
# "${image}" \
# /bin/sh -xec "cd /home/iojs/workspace && . ./$exec_script"

container=$(docker run \
--init \
--rm \
-d \
-v $(pwd):/home/iojs/workspace \
-v /home/iojs/.ccache/${image_tag}:/home/iojs/.ccache \
-u iojs \
"${image}" \
tail -f /dev/null)

sleep 2

echo -e "Container is running ($image_tag)...\n"
docker exec $container /bin/sh -c "cat /etc/os-release || true"
echo -e "\n"

set +e
docker exec -i $container /bin/bash -xec "cd /home/iojs/workspace && . ./$exec_script"
exit_code=$?

docker stop $container

exit $exit_code
4 changes: 4 additions & 0 deletions ansible/roles/jenkins-worker/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@
cmd: "./bootstrap --verbose && make -j6 VERBOSE=1 && make install"
creates: "/usr/local/bin/cmake"

- name: run docker-host-x64 jenkins-worker setup
when: "'_docker-x64' in inventory_hostname"
include: "{{ role_path }}/tasks/partials/docker-host-x64.yml"

# @TODO(mhdawson): get tap2junit working on zOS
- name: prepare installing tap2junit
when: type != "release" and not os|startswith("zos")
Expand Down
30 changes: 30 additions & 0 deletions ansible/roles/jenkins-worker/tasks/partials/docker-host-x64.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---

- name: docker-host-x64 | check if docker exists
shell: which docker
register: docker_exists
ignore_errors: yes

- name: docker-host-x64 | install docker from docker.com
when: "docker_exists.stdout == ''"
raw: curl -fsSL get.docker.com | bash -

- name: docker-host-x64 | copy docker-node-exec.sh
copy:
src: "{{ role_path }}/files/docker-node-exec.sh"
dest: "/usr/local/bin/docker-node-exec.sh"
owner: root
group: root
mode: 0755

- name: docker-host-x64 | give {{ server_user }} sudoers access to docker-exec script
lineinfile:
line: "{{ server_user }} ALL=(ALL) NOPASSWD: /usr/local/bin/docker-node-exec.sh"
dest: "/etc/sudoers"
regexp: docker-node-exec.sh$

- name: docker-host-x64 | install shyaml
pip:
name: shyaml
state: present
executable: pip3
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@
# ubuntu series: python 2.7
#

# TODO(@rvagg): a hack, how do we handle py3?

- name: install pip
package: name=python-pip state=present
when: os != "ubuntu2004"

- name: install tap2junit
pip: name=tap2junit state=present
when: os != "ubuntu2004"
2 changes: 1 addition & 1 deletion ansible/roles/jenkins-worker/vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ init: {
ibmi: 'ibmi72',
macos: 'macos',
rhel7: 'rhel7',
systemd: ['centos7', 'debian8', 'debian9', 'debian10', 'fedora', 'ubuntu1604', 'ubuntu1804'],
systemd: ['centos7', 'debian8', 'debian9', 'debian10', 'fedora', 'ubuntu1604', 'ubuntu1804', 'ubuntu2004'],
svc: 'smartos',
upstart: ['ubuntu12', 'ubuntu1404'],
zos_start: 'zos'
Expand Down