Hello! In this post, I will leave the Dockerfile and requirements.txt files for creating the base image that I will use in Kubernetes / Jenkins from now on. https://github.com/faustobranco/devops-db/tree/master/Initial%20Images/img-jenkins-devopsdb

Current version: 2.0 (18/06/2024)

Dockerfile:

FROM jenkins/jenkins:lts-slim-jdk17

USER root

ENV WORKDIR /pipeline
RUN mkdir -p ${WORKDIR}
WORKDIR ${WORKDIR}

RUN apt update\
    && apt install -y python3=3.11.2-1+b1\
    && apt install -y wget vim curl python3-pip less git

ADD requirements.txt ${WORKDIR}/requirements.txt
RUN pip3 install -r ${WORKDIR}/requirements.txt --break-system-packages

# Pipelines with Blue Ocean UI and Kubernetes
RUN jenkins-plugin-cli --plugins blueocean kubernetes

requirements.txt

###### Requirements without Version Specifiers ######
python-gitlab
docker

Build.

Just to check, which base image Jenkins uses in its image:

$ docker run jenkins/jenkins:lts-slim-jdk17 cat /etc/*release*

PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"

Build the image:

$ docker build -t img-jenkins-devopsdb:2.0 .

docker@minikube:~/tmp$ docker build -t img-jenkins-devopsdb:2.0 .
[+] Building 125.7s (12/12) FINISHED           
[...]

Now tag and upload the image to our registry:

docker image tag img-jenkins-devopsdb:2.0 registry.devops-db.internal:5000/img-jenkins-devopsdb:2.0
docker image push registry.devops-db.internal:5000/img-jenkins-devopsdb:2.0

Check:

curl http://registry.devops-db.internal:5000/v2/img-jenkins-devopsdb/tags/list
{"name":"img-jenkins-devopsdb","tags":["2.0","1.0"]}

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.