-
Notifications
You must be signed in to change notification settings - Fork 166
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
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
50bfa39
TMP FIXME
rvagg 8a76e60
ansible: docker-host-x64 setup
rvagg d03da9d
fixup! ansible: docker-host-x64 setup
rvagg a7e740b
fixup! ansible: docker-host-x64 setup
rvagg 7b02b79
switch docker-hosts to 1910
rvagg a857e05
try 20.04 docker host
rvagg 2de2393
python3 hack
rvagg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,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" | ||
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 |
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
30 changes: 30 additions & 0 deletions
30
ansible/roles/jenkins-worker/tasks/partials/docker-host-x64.yml
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,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 |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.