From: Sankar Palanivel Date: Thu, 13 Oct 2022 13:31:45 +0000 (+0100) Subject: Add Dockerfile for Jenkins Kubernetes plugin build agents X-Git-Url: https://gerrit.nordix.org/gitweb?p=infra%2Ftools.git;a=commitdiff_plain;h=bc8479804a5928116b9d0254aec054eff5e4d435 Add Dockerfile for Jenkins Kubernetes plugin build agents In this change, - Added a Dockerfile which can be used to create container image for jenkins agent with jdk-11 version for the Jenkins Kubernetes plugin build agents Change-Id: I0a280d954410bc4699ec3a815cc8aaa3ae012d8e --- diff --git a/infra/jenkins/slave-setup/kubernetes-slave/Dockerfile b/infra/jenkins/slave-setup/kubernetes-slave/Dockerfile new file mode 100644 index 0000000..2436867 --- /dev/null +++ b/infra/jenkins/slave-setup/kubernetes-slave/Dockerfile @@ -0,0 +1,65 @@ +# ============LICENSE_START======================================================= +# Copyright (C) 2022 The Nordix Foundation. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# ============LICENSE_END========================================================= + +#------------------------------------------------------------------------------- +# This Dockerfile is used for building container images to +# use as Jenkins Slaves for Nordix Infra. The image is configured +# and tested for running +# - Jenkins Job Builder Verify and Merge jobs using tox +# - Cloud Infra Engine ansible-lint, yamllist, and shellcheck using tox +# - ONAP report generation +# +# The image built using this Dockerfile is currently being stored on Nordix Registry +# with the name nordixorg/infra-tools-kubernetes-jnlp-slave:jdk11 which can be seen +# using the link below. +# https://registry.nordix.org/harbor/projects/29/repositories/infra-tools-kubernetes-jnlp-slave +# The images are automatically attached to Jenkins as slaves using Jenkins +# Kubernetes plugin with a name that looks like infra-tools-kubernetes-slave-ubuntu1804- +# +# In order to use this image as slave for your jobs, you need to use label +# infra-tools-kubernetes-slave-ubuntu1804 so Jenkins schedules your job on this slave +# which gets provisioned by Jenkins Kubernetes plugin. Please note that it takes few +# seconds before the slave becomes ready and job starts running. +#------------------------------------------------------------------------------- +FROM jenkins/jnlp-slave:latest-jdk11 +USER root +# we need few basic packages in order to use base image as Jenkins slave +RUN apt update +RUN apt upgrade -o Dpkg::Options::=--force-confdef -o \ + Dpkg::Options::=--force-confnew -q=3 -y +RUN apt install -o Dpkg::Options::=--force-confdef -o \ + Dpkg::Options::=--force-confnew -q=3 -y git vim sudo \ + software-properties-common wget jq gnupg +# add ubuntu repos for python3.6-minimal and the key +RUN add-apt-repository 'deb [arch=amd64] http://archive.ubuntu.com/ubuntu focal main universe' +RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 3B4FE6ACC0B21F32 +RUN apt update +# we need yq for ONAP report generation +RUN wget -O /usr/local/bin/yq https://github.com/mikefarah/yq/releases/download/3.3.0/yq_linux_amd64 +RUN chmod +x /usr/local/bin/yq +# we install system packages as part of Jenkins verify jobs so +# jenkins user needs to be able to run sudo +RUN usermod -aG sudo jenkins +# without tty +RUN sed -i "s/^Defaults.*env_reset/#&\nDefaults:jenkins \!requiretty/" /etc/sudoers +# and without password +RUN sed -i "s/^%sudo.*ALL/%sudo ALL=(ALL:ALL) NOPASSWD: ALL/" /etc/sudoers +# switch back to jenkins user +USER jenkins +# create slave_root folder same as what we use on regular slaves +RUN mkdir -p /home/jenkins/nordix/slave_root \ No newline at end of file