Skip to content

Commit

Permalink
add jenkins slave
Browse files Browse the repository at this point in the history
  • Loading branch information
apporc committed Feb 23, 2023
1 parent 2fef6fc commit ec6e9ad
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 0 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/jenkins-slave.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Jenkins slave Docker Image Build

on:
workflow_dispatch:
inputs:

env:
REGISTRY: ghcr.io
IMAGE_NAME: greymass/jenkins-slave

jobs:
docker:
runs-on: ubuntu-latest
steps:

- name: Checkout
uses: actions/checkout@v2

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: latest

- name: Log in to the Container registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v2
with:
context: ./jenkins-slave/
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
1 change: 1 addition & 0 deletions jenkins-slave/010_jenkins-nopasswd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
jenkins ALL=(ALL) NOPASSWD: ALL
48 changes: 48 additions & 0 deletions jenkins-slave/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
FROM jenkins/inbound-agent

USER root
RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get install -y --no-install-recommends \
locales \
sudo \
vim \
curl \
telnet \
git \
tmux \
gcc \
gnupg \
python3 \
python3-pip \
python3-wheel \
ansible \
tox \
ca-certificates \
apt-transport-https \
software-properties-common \
&& localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 \
&& curl -sSL https://download.docker.com/linux/debian/gpg -o /tmp/docker.gpg \
&& apt-key add /tmp/docker.gpg \
&& rm /tmp/docker.gpg \
&& add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" \
&& curl -sSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key -o /tmp/node.gpg \
&& apt-key add /tmp/node.gpg \
&& rm /tmp/node.gpg \
&& echo "deb https://deb.nodesource.com/node_16.x $(lsb_release -cs) main" > /etc/apt/sources.list.d/nodesource.list \
&& echo "deb-src https://deb.nodesource.com/node_16.x $(lsb_release -cs) main" >> /etc/apt/sources.list.d/nodesource.list \
&& apt-get update \
&& apt-cache policy docker-ce \
&& apt-get install -y --no-install-recommends docker-ce nodejs \
&& update-alternatives --remove python /usr/bin/python2 \
&& update-alternatives --install /usr/bin/python python /usr/bin/python3 10 \
&& update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 10 \
&& rm -rf /var/lib/apt/lists/*

RUN usermod -aG docker jenkins

RUN pip install --no-cache-dir pbr devpi-client

COPY 010_jenkins-nopasswd /etc/sudoers.d/

USER jenkins
1 change: 1 addition & 0 deletions jenkins-slave/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
customized jenkins slave container

0 comments on commit ec6e9ad

Please sign in to comment.