Meridio: Update to golang 1.22
[infra/tools.git] / infra / jenkins / slave-setup / docker-slave / Dockerfile
1 # ============LICENSE_START=======================================================
2 #  Copyright (C) 2019 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
7 #
8 #      http://www.apache.org/licenses/LICENSE-2.0
9 #
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.
15 #
16 # SPDX-License-Identifier: Apache-2.0
17 # ============LICENSE_END=========================================================
18
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 #   - ONAP report generation
25 #
26 # The image built using this Dockerfile is currently being stored on Nordix registry
27 # with the name nordixorg/infra-tools-docker-slave-ubuntu1804 which can be seen
28 # using the link below.
29 #   https://registry.nordix.org/harbor/projects/29/repositories/infra-tools-docker-slave-ubuntu1804
30 # The images are automatically attached to Jenkins as slaves using Jenkins
31 # Docker plugin with a name that looks like infra-ubuntu1804-<random_characters>
32 #
33 # In order to use this image as slave for your jobs, you need to use label
34 # infra-tools-docker-slave-ubuntu1804 so Jenkins schedules your job on this slave
35 # which gets provisioned by Jenkins Docker plugin. Please note that it takes few
36 # seconds before the slave becomes ready and job starts running.
37 #-------------------------------------------------------------------------------
38 # Please use this docker file to build new Nordix docker slave image.
39 # Here are the steps required to build and upload the new image to Nordix registry
40 # 1. Login to Nordix Harbor with account that have write access to nordixorg repository
41 #    $ docker login registry.nordix.org
42 # 2. Build new image using the correct path and tag version. For example:
43 #    $ docker build . -t "registry.nordix.org/nordixorg/infra-tools-docker-slave-ubuntu1804:5-jdk11"
44 # 3. Upload new image to Nordix registry
45 #    $ docker push registry.nordix.org/nordixorg/infra-tools-docker-slave-ubuntu1804:5-jdk11
46 #-------------------------------------------------------------------------------
47 FROM jenkins/jnlp-slave:latest-jdk11
48 USER root
49 # we need few basic packages in order to use base image as Jenkins slave
50 RUN apt update
51 RUN apt upgrade -o Dpkg::Options::=--force-confdef -o \
52     Dpkg::Options::=--force-confnew -q=3 -y
53 RUN apt install -o Dpkg::Options::=--force-confdef -o \
54     Dpkg::Options::=--force-confnew -q=3 -y git vim sudo \
55     software-properties-common wget jq gnupg
56 # FixMe: New version of Jenkins LTS 2.426.1 requires agent version 4.13 or newer
57 # 13 Dec 2023: The latest jnlp-slave base image contains agent 4.9
58 # https://hub.docker.com/r/jenkins/jnlp-slave/tags
59 ENV VERSION=4.14
60 RUN curl --create-dirs -fsSLo /usr/share/jenkins/agent.jar https://repo.jenkins-ci.org/public/org/jenkins-ci/main/remoting/${VERSION}/remoting-${VERSION}.jar  && chmod 644 /usr/share/jenkins/agent.jar && chown jenkins:jenkins /usr/share/jenkins/agent.jar
61 # add ubuntu repos for python3.6-minimal and the key
62 RUN add-apt-repository 'deb [arch=amd64] http://archive.ubuntu.com/ubuntu bionic main'
63 RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 3B4FE6ACC0B21F32
64 RUN apt update
65 # we need yq for ONAP report generation
66 RUN wget -O /usr/local/bin/yq https://github.com/mikefarah/yq/releases/download/3.3.0/yq_linux_amd64
67 RUN chmod +x /usr/local/bin/yq
68 # we install system packages as part of Jenkins verify jobs so
69 # jenkins user needs to be able to run sudo
70 RUN usermod -aG sudo jenkins
71 # without tty
72 RUN sed -i "s/^Defaults.*env_reset/#&\nDefaults:jenkins  \!requiretty/" /etc/sudoers
73 # and without password
74 RUN sed -i "s/^%sudo.*ALL/%sudo  ALL=(ALL:ALL)   NOPASSWD: ALL/" /etc/sudoers
75 # switch back to jenkins user
76 USER jenkins
77 # create slave_root folder same as what we use on regular slaves
78 RUN mkdir -p /home/jenkins/nordix/slave_root