1 # ============LICENSE_START=======================================================
2 # Copyright (C) 2022 The Nordix Foundation. All rights reserved.
3 # ================================================================================
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
16 # SPDX-License-Identifier: Apache-2.0
17 # ============LICENSE_END=========================================================
19 #-------------------------------------------------------------------------------
20 # This Dockerfile is used for building container images to
21 # use as Jenkins Slaves for Nordix Infra. The image is configured
22 # and tested for running
23 # - Jenkins Job Builder Verify and Merge jobs using tox
24 # - Cloud Infra Engine ansible-lint, yamllist, and shellcheck using tox
25 # - ONAP report generation
27 # The image built using this Dockerfile is currently being stored on Nordix Registry
28 # with the name nordixorg/infra-tools-kubernetes-jnlp-slave:jdk11 which can be seen
29 # using the link below.
30 # https://registry.nordix.org/harbor/projects/29/repositories/infra-tools-kubernetes-jnlp-slave
31 # The images are automatically attached to Jenkins as slaves using Jenkins
32 # Kubernetes plugin with a name that looks like infra-tools-kubernetes-slave-ubuntu1804-<random_characters>
34 # In order to use this image as slave for your jobs, you need to use label
35 # infra-tools-kubernetes-slave-ubuntu1804 so Jenkins schedules your job on this slave
36 # which gets provisioned by Jenkins Kubernetes plugin. Please note that it takes few
37 # seconds before the slave becomes ready and job starts running.
38 #-------------------------------------------------------------------------------
39 FROM jenkins/jnlp-slave:latest-jdk11
41 # we need few basic packages in order to use base image as Jenkins slave
43 RUN apt upgrade -o Dpkg::Options::=--force-confdef -o \
44 Dpkg::Options::=--force-confnew -q=3 -y
45 RUN apt install -o Dpkg::Options::=--force-confdef -o \
46 Dpkg::Options::=--force-confnew -q=3 -y git vim sudo \
47 software-properties-common wget jq gnupg
48 # add ubuntu repos for python3.6-minimal and the key
49 RUN add-apt-repository 'deb [arch=amd64] http://archive.ubuntu.com/ubuntu focal main universe'
50 RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 3B4FE6ACC0B21F32
52 # we need yq for ONAP report generation
53 RUN wget -O /usr/local/bin/yq https://github.com/mikefarah/yq/releases/download/3.3.0/yq_linux_amd64
54 RUN chmod +x /usr/local/bin/yq
55 # we install system packages as part of Jenkins verify jobs so
56 # jenkins user needs to be able to run sudo
57 RUN usermod -aG sudo jenkins
59 RUN sed -i "s/^Defaults.*env_reset/#&\nDefaults:jenkins \!requiretty/" /etc/sudoers
60 # and without password
61 RUN sed -i "s/^%sudo.*ALL/%sudo ALL=(ALL:ALL) NOPASSWD: ALL/" /etc/sudoers
62 # switch back to jenkins user
64 # create slave_root folder same as what we use on regular slaves
65 RUN mkdir -p /home/jenkins/nordix/slave_root