Ensure we can install python3.6 in docker slave
[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 #   - Cloud Infra Engine ansible-lint, yamllist, and shellcheck using tox
25 #
26 # The image built using this Dockerfile is currently being stored on Docker Hub
27 # with the name nordixorg/infra-tools-docker-slave-ubuntu1804 which can be seen
28 # using the link below.
29 #   https://hub.docker.com/repository/docker/nordixorg/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 FROM jenkins/jnlp-slave
39 USER root
40 # we need few basic packages in order to use base image as Jenkins slave
41 RUN apt update
42 RUN apt install -o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confnew -q=3 -y git vim sudo software-properties-common
43 # add ubuntu repos for python3.6-minimal and the key
44 RUN add-apt-repository 'deb [arch=amd64] http://archive.ubuntu.com/ubuntu bionic main'
45 RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 3B4FE6ACC0B21F32
46 RUN apt update
47 # we install system packages as part of Jenkins verify jobs so
48 # jenkins user needs to be able to run sudo
49 RUN usermod -aG sudo jenkins
50 # without tty
51 RUN sed -i "s/^Defaults.*env_reset/#&\nDefaults:jenkins  \!requiretty/" /etc/sudoers
52 # and without password
53 RUN sed -i "s/^%sudo.*ALL/%sudo  ALL=(ALL:ALL)   NOPASSWD: ALL/" /etc/sudoers
54 # switch back to jenkins user
55 USER jenkins
56 # create slave_root folder same as what we use on regular slaves
57 RUN mkdir -p /home/jenkins/nordix/slave_root