From ae75a978b9d69f5bb5f079de373843ccce430b9a Mon Sep 17 00:00:00 2001 From: Rod Vagg Date: Tue, 14 Jun 2016 12:27:02 +1000 Subject: [PATCH 1/3] added preliminary Alpine support --- setup/ansible-inventory | 3 + setup/ubuntu16.04_docker_alpine3.4/.gitignore | 2 + setup/ubuntu16.04_docker_alpine3.4/README.md | 17 +++++ .../ansible-playbook.yaml | 76 +++++++++++++++++++ .../ansible-vars.yaml | 4 + .../ubuntu16.04_docker_alpine3.4/ansible.cfg | 2 + .../requirements.yml | 1 + .../resources/Dockerfile.j2 | 47 ++++++++++++ .../resources/jenkins.service.j2 | 16 ++++ 9 files changed, 168 insertions(+) create mode 100644 setup/ubuntu16.04_docker_alpine3.4/.gitignore create mode 100644 setup/ubuntu16.04_docker_alpine3.4/README.md create mode 100644 setup/ubuntu16.04_docker_alpine3.4/ansible-playbook.yaml create mode 100644 setup/ubuntu16.04_docker_alpine3.4/ansible-vars.yaml create mode 100644 setup/ubuntu16.04_docker_alpine3.4/ansible.cfg create mode 100644 setup/ubuntu16.04_docker_alpine3.4/requirements.yml create mode 100644 setup/ubuntu16.04_docker_alpine3.4/resources/Dockerfile.j2 create mode 100644 setup/ubuntu16.04_docker_alpine3.4/resources/jenkins.service.j2 diff --git a/setup/ansible-inventory b/setup/ansible-inventory index 13f855977..5bba53129 100644 --- a/setup/ansible-inventory +++ b/setup/ansible-inventory @@ -196,3 +196,6 @@ node-win2012r2-x64-3.cloudapp.net [github-bot] infra-rackspace-debian8-x64-1 + +[test-ubuntu1604_docker_alpine34] +test-digitalocean-ubuntu1604_docker_alpine34-x64-1 diff --git a/setup/ubuntu16.04_docker_alpine3.4/.gitignore b/setup/ubuntu16.04_docker_alpine3.4/.gitignore new file mode 100644 index 000000000..8809e43dd --- /dev/null +++ b/setup/ubuntu16.04_docker_alpine3.4/.gitignore @@ -0,0 +1,2 @@ +host_vars/test-* +roles/* diff --git a/setup/ubuntu16.04_docker_alpine3.4/README.md b/setup/ubuntu16.04_docker_alpine3.4/README.md new file mode 100644 index 000000000..799ce7e6a --- /dev/null +++ b/setup/ubuntu16.04_docker_alpine3.4/README.md @@ -0,0 +1,17 @@ +# Alpine Linux 3.4 via Docker on Ubuntu 16.04 Setup + +Add this to your ssh config: + +```text +Host test-digitalocean-ubuntu1604_adocker_alpine34-x64-1 + HostName 107.170.75.204 + User root + #IdentityFile nodejs_build_test +``` + +..then run: + +```bash +$ ansible-galaxy install -p . angstwad.docker_ubuntu +$ ansible-playbook -i ../ansible-inventory ansible-playbook.yaml +``` diff --git a/setup/ubuntu16.04_docker_alpine3.4/ansible-playbook.yaml b/setup/ubuntu16.04_docker_alpine3.4/ansible-playbook.yaml new file mode 100644 index 000000000..b5e14ea3a --- /dev/null +++ b/setup/ubuntu16.04_docker_alpine3.4/ansible-playbook.yaml @@ -0,0 +1,76 @@ +--- +- hosts: test-ubuntu1604_docker_alpine34 + remote_user: root + gather_facts: False + + tasks: + - name: Check for python + raw: which python + register: python_exists + failed_when: python_exists.rc > 1 + + - name: Bootstrap for the apt package + raw: apt install -y python-minimal aptitude + tags: bootstrap + when: python_exists.rc == 1 + +- hosts: test-ubuntu1604_docker_alpine34 + remote_user: root + gather_facts: True + + tasks: + - include_vars: ansible-vars.yaml + tags: vars + + - name: General | APT Update and upgrade + apt: update_cache=yes upgrade=full + tags: general + + - name: General | Install required packages + apt: name={{ item }} update_cache=yes state=latest + with_items: packages + tags: general + + - name: User | Add {{ server_user }} user + user: name="{{ server_user }}" shell=/bin/bash + tags: user + + - name: User | Make work directories + file: + path: "/home/{{ server_user }}/{{ item }}" + state: directory + mode: 0755 + owner: "{{ server_user }}" + group: "{{ server_user }}" + with_items: + - build + - tmp + tags: user + +- name: Docker | Install Docker + hosts: test-ubuntu1604_docker_alpine34 + remote_user: root + gather_facts: True + roles: + - angstwad.docker_ubuntu + tags: docker + +- hosts: test-ubuntu1604_docker_alpine34 + remote_user: root + gather_facts: True + + tasks: + - name: Docker | Generate Dockerfile + template: src=./resources/Dockerfile.j2 dest=/root/Dockerfile + tags: docker + + - name: Docker | Build Alpine image + command: docker build -t node-ci:alpine-build /root/ + + - name: Init | Generate and copy init script + template: src=./resources/jenkins.service.j2 dest=/lib/systemd/system/jenkins.service + tags: init + + - name: Init | Start Jenkins + service: name=jenkins state=started enabled=yes + tags: init diff --git a/setup/ubuntu16.04_docker_alpine3.4/ansible-vars.yaml b/setup/ubuntu16.04_docker_alpine3.4/ansible-vars.yaml new file mode 100644 index 000000000..4be2eb6ac --- /dev/null +++ b/setup/ubuntu16.04_docker_alpine3.4/ansible-vars.yaml @@ -0,0 +1,4 @@ +--- +server_user: iojs +packages: + - curl diff --git a/setup/ubuntu16.04_docker_alpine3.4/ansible.cfg b/setup/ubuntu16.04_docker_alpine3.4/ansible.cfg new file mode 100644 index 000000000..9af689044 --- /dev/null +++ b/setup/ubuntu16.04_docker_alpine3.4/ansible.cfg @@ -0,0 +1,2 @@ +[defaults] +roles_path = ./roles/ diff --git a/setup/ubuntu16.04_docker_alpine3.4/requirements.yml b/setup/ubuntu16.04_docker_alpine3.4/requirements.yml new file mode 100644 index 000000000..566f69dd3 --- /dev/null +++ b/setup/ubuntu16.04_docker_alpine3.4/requirements.yml @@ -0,0 +1 @@ +- src: angstwad.docker_ubuntu diff --git a/setup/ubuntu16.04_docker_alpine3.4/resources/Dockerfile.j2 b/setup/ubuntu16.04_docker_alpine3.4/resources/Dockerfile.j2 new file mode 100644 index 000000000..8e1aa64a2 --- /dev/null +++ b/setup/ubuntu16.04_docker_alpine3.4/resources/Dockerfile.j2 @@ -0,0 +1,47 @@ +FROM alpine:3.4 + +ENV LC_ALL C +ENV USER {{ server_user }} +ENV JOBS {{ server_jobs | default(ansible_processor_vcpus) }} +ENV HOME /home/{{ server_user }} +ENV NODE_TEST_DIR /home/{{ server_user }}/tmp +ENV PATH /usr/lib/ccache/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin +ENV NODE_COMMON_PIPE /home/{{ server_user }}/test.pipe +ENV OSTYPE linux-gnu +ENV DESTCPU x64 +ENV ARCH x64 + +RUN apk add --no-cache \ + libstdc++ \ + && apk add --no-cache --virtual .build-deps \ + binutils-gold \ + curl \ + g++ \ + gcc \ + gnupg \ + libgcc \ + linux-headers \ + make \ + paxctl \ + python \ + tar \ + ccache \ + openjdk8 \ + git \ + procps \ + openssh-client + +RUN addgroup -g 1000 {{ server_user }} + +RUN adduser -G {{ server_user }} -D -u 1000 {{ server_user }} + +VOLUME [ "/home/{{ server_user }}/" ] + +USER iojs + +CMD cd /home/iojs \ + && curl https://ci.nodejs.org/jnlpJars/slave.jar -O \ + && java \ + -jar slave.jar \ + -jnlpUrl https://ci.nodejs.org/computer/test-digitalocean-ubuntu1604_docker_alpine34-x64-1/slave-agent.jnlp \ + -secret efbfadbf4807af0f1084a1e120ef5467b49432113661e11ce2ecc1ab71b96f38 diff --git a/setup/ubuntu16.04_docker_alpine3.4/resources/jenkins.service.j2 b/setup/ubuntu16.04_docker_alpine3.4/resources/jenkins.service.j2 new file mode 100644 index 000000000..9d8e2f42b --- /dev/null +++ b/setup/ubuntu16.04_docker_alpine3.4/resources/jenkins.service.j2 @@ -0,0 +1,16 @@ +[Unit] +Description=Jenkins Slave in Docker +Wants=network.target +After=network.target + +[Install] +WantedBy=multi-user.target + +[Service] +Type=simple +User=root +ExecStart=/usr/bin/docker run --rm -v /home/{{ server_user }}:/home/{{ server_user }} --name node-ci-alpine node-ci:alpine-build +ExecStop=/usr/bin/docker stop -t 5 node-ci-alpine +Restart=always +RestartSec=30 +StartLimitInterval=0 From 344262aec6e7675ea6e138064a8bd8ed50ce458c Mon Sep 17 00:00:00 2001 From: Rod Vagg Date: Wed, 31 Aug 2016 20:56:20 +1000 Subject: [PATCH 2/3] alpine: add bash --- setup/ubuntu16.04_docker_alpine3.4/resources/Dockerfile.j2 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup/ubuntu16.04_docker_alpine3.4/resources/Dockerfile.j2 b/setup/ubuntu16.04_docker_alpine3.4/resources/Dockerfile.j2 index 8e1aa64a2..d304406eb 100644 --- a/setup/ubuntu16.04_docker_alpine3.4/resources/Dockerfile.j2 +++ b/setup/ubuntu16.04_docker_alpine3.4/resources/Dockerfile.j2 @@ -29,7 +29,8 @@ RUN apk add --no-cache \ openjdk8 \ git \ procps \ - openssh-client + openssh-client \ + bash RUN addgroup -g 1000 {{ server_user }} From 10117d2a53e8ea6bd3cb62c9813801ed9f861aac Mon Sep 17 00:00:00 2001 From: Rod Vagg Date: Thu, 1 Sep 2016 20:07:31 +1000 Subject: [PATCH 3/3] alpine: add release container --- .../ansible-playbook.yaml | 36 ++++++++++------ .../resources/.gitignore | 1 + .../resources/Dockerfile.j2 | 5 ++- .../resources/jenkins.service.j2 | 4 +- .../resources/release_ssh_config | 4 ++ .../tasks/setup-image.yaml | 41 +++++++++++++++++++ 6 files changed, 75 insertions(+), 16 deletions(-) create mode 100644 setup/ubuntu16.04_docker_alpine3.4/resources/.gitignore create mode 100644 setup/ubuntu16.04_docker_alpine3.4/resources/release_ssh_config create mode 100644 setup/ubuntu16.04_docker_alpine3.4/tasks/setup-image.yaml diff --git a/setup/ubuntu16.04_docker_alpine3.4/ansible-playbook.yaml b/setup/ubuntu16.04_docker_alpine3.4/ansible-playbook.yaml index b5e14ea3a..e564eb648 100644 --- a/setup/ubuntu16.04_docker_alpine3.4/ansible-playbook.yaml +++ b/setup/ubuntu16.04_docker_alpine3.4/ansible-playbook.yaml @@ -22,7 +22,7 @@ - include_vars: ansible-vars.yaml tags: vars - - name: General | APT Update and upgrade + - name: General | APT update and upgrade apt: update_cache=yes upgrade=full tags: general @@ -60,17 +60,29 @@ gather_facts: True tasks: - - name: Docker | Generate Dockerfile - template: src=./resources/Dockerfile.j2 dest=/root/Dockerfile - tags: docker + - include: tasks/setup-image.yaml image_type=test ci_host=ci.nodejs.org secret={{ test_secret }} + - include: tasks/setup-image.yaml image_type=release ci_host=ci-release.nodejs.org secret={{ release_secret }} - - name: Docker | Build Alpine image - command: docker build -t node-ci:alpine-build /root/ + - name: SSH | Make release ssh config directory + file: + path: "/home/{{ server_user }}/release/.ssh/" + state: directory + mode: 0700 + owner: "{{ server_user }}" + tags: docker_build - - name: Init | Generate and copy init script - template: src=./resources/jenkins.service.j2 dest=/lib/systemd/system/jenkins.service - tags: init + - name: SSH | Copy release ssh config + template: + src: ./resources/release_ssh_config + dest: "/home/{{ server_user }}/release/.ssh/config" + mode: 0600 + owner: "{{ server_user }}" + tags: docker_init - - name: Init | Start Jenkins - service: name=jenkins state=started enabled=yes - tags: init + - name: SSH | Copy release ssh staging key + template: + src: ./resources/node-www-staging-key + dest: "/home/{{ server_user }}/release/.ssh/node-www-staging" + mode: 0600 + owner: "{{ server_user }}" + tags: docker_init diff --git a/setup/ubuntu16.04_docker_alpine3.4/resources/.gitignore b/setup/ubuntu16.04_docker_alpine3.4/resources/.gitignore new file mode 100644 index 000000000..c0d7a319e --- /dev/null +++ b/setup/ubuntu16.04_docker_alpine3.4/resources/.gitignore @@ -0,0 +1 @@ +node-www-staging-key \ No newline at end of file diff --git a/setup/ubuntu16.04_docker_alpine3.4/resources/Dockerfile.j2 b/setup/ubuntu16.04_docker_alpine3.4/resources/Dockerfile.j2 index d304406eb..694f58274 100644 --- a/setup/ubuntu16.04_docker_alpine3.4/resources/Dockerfile.j2 +++ b/setup/ubuntu16.04_docker_alpine3.4/resources/Dockerfile.j2 @@ -8,6 +8,7 @@ ENV NODE_TEST_DIR /home/{{ server_user }}/tmp ENV PATH /usr/lib/ccache/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin ENV NODE_COMMON_PIPE /home/{{ server_user }}/test.pipe ENV OSTYPE linux-gnu +ENV OSVARIANT docker ENV DESTCPU x64 ENV ARCH x64 @@ -44,5 +45,5 @@ CMD cd /home/iojs \ && curl https://ci.nodejs.org/jnlpJars/slave.jar -O \ && java \ -jar slave.jar \ - -jnlpUrl https://ci.nodejs.org/computer/test-digitalocean-ubuntu1604_docker_alpine34-x64-1/slave-agent.jnlp \ - -secret efbfadbf4807af0f1084a1e120ef5467b49432113661e11ce2ecc1ab71b96f38 + -jnlpUrl https://{{ ci_host }}/computer/{{ image_type }}-digitalocean-ubuntu1604_docker_alpine34-x64-1/slave-agent.jnlp \ + -secret {{ secret }} diff --git a/setup/ubuntu16.04_docker_alpine3.4/resources/jenkins.service.j2 b/setup/ubuntu16.04_docker_alpine3.4/resources/jenkins.service.j2 index 9d8e2f42b..d9d62cdf0 100644 --- a/setup/ubuntu16.04_docker_alpine3.4/resources/jenkins.service.j2 +++ b/setup/ubuntu16.04_docker_alpine3.4/resources/jenkins.service.j2 @@ -9,8 +9,8 @@ WantedBy=multi-user.target [Service] Type=simple User=root -ExecStart=/usr/bin/docker run --rm -v /home/{{ server_user }}:/home/{{ server_user }} --name node-ci-alpine node-ci:alpine-build -ExecStop=/usr/bin/docker stop -t 5 node-ci-alpine +ExecStart=/usr/bin/docker run --rm -v /home/{{ server_user }}/{{ image_type }}:/home/{{ server_user }} --name node-ci-alpine-{{ image_type }} node-ci:alpine-{{ image_type }} +ExecStop=/usr/bin/docker stop -t 5 node-ci-alpine-{{ image_type }} Restart=always RestartSec=30 StartLimitInterval=0 diff --git a/setup/ubuntu16.04_docker_alpine3.4/resources/release_ssh_config b/setup/ubuntu16.04_docker_alpine3.4/resources/release_ssh_config new file mode 100644 index 000000000..e581f840e --- /dev/null +++ b/setup/ubuntu16.04_docker_alpine3.4/resources/release_ssh_config @@ -0,0 +1,4 @@ +Host iojs-www node-www + HostName direct.nodejs.org + User staging + IdentityFile ~/.ssh/node-www-staging \ No newline at end of file diff --git a/setup/ubuntu16.04_docker_alpine3.4/tasks/setup-image.yaml b/setup/ubuntu16.04_docker_alpine3.4/tasks/setup-image.yaml new file mode 100644 index 000000000..ce5728b81 --- /dev/null +++ b/setup/ubuntu16.04_docker_alpine3.4/tasks/setup-image.yaml @@ -0,0 +1,41 @@ +--- +# requires: @image_type +# requires: @ci_host +# requires: @secret + +- name: Docker | Make build directory + file: + path: /root/{{ image_type }} + state: directory + tags: docker_build + +- name: Docker | Generate Dockerfile + template: + src: ./resources/Dockerfile.j2 + dest: /root/{{ image_type }}/Dockerfile + tags: docker_build + +- name: Docker | Build Alpine image + command: docker build -t node-ci:alpine-{{ image_type }} /root/{{ image_type }}/ + tags: docker_build + +- name: Docker | Make mountable home directory + file: + path: "/home/{{ server_user }}/{{ image_type }}" + state: directory + mode: 0755 + owner: "{{ server_user }}" + tags: docker_build + +- name: Init | Generate and copy init script + template: + src: ./resources/jenkins.service.j2 + dest: /lib/systemd/system/jenkins-{{ image_type }}.service + tags: docker_init + +- name: Init | Start Jenkins + service: + name: jenkins-{{ image_type }} + state: started + enabled: yes + tags: docker_init