This is the first base image for Docker and Python that I will create, so I will create others according to the need, but no longer manual, they must all be created with Pipelines and blueprints, even this one, must then be redone using the process, but for the first one, it needs to be manual.
It is an Ubuntu 22.04 image. with Python3 and a few extras and some Python modules. This image will only be used for the first Pipelines.
It will also be uploaded to our Registry.
I will leave here the Link to GitHub with the Dockerfile and requirements.txt. https://github.com/faustobranco/devops-db/tree/master/Initial%20Images/ubuntu
Files.
Dockerfile:
FROM ubuntu:22.04
USER root
ENV WORKDIR /pipeline
RUN mkdir -p ${WORKDIR}
WORKDIR ${WORKDIR}
RUN apt update\
&& apt install -y python3=3.10.6-1~22.04\
&& apt install -y wget vim curl python3-pip less git
ADD requirements.txt ${WORKDIR}/requirements.txt
RUN pip3 install -r ${WORKDIR}/requirements.txt
requirements.txt
###### Requirements without Version Specifiers ######
python-gitlab
docker
Image Creation
docker image build --rm --no-cache --platform linux/amd64 -t ubuntu_python:3.10.6 /work/base_docker_image/ubuntu_python
docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu_python 3.10.6 13c81d4c7f0b 20 minutes ago 555MB
Upload to Registry:
docker image tag ubuntu_python:3.10.6 registry.devops-db.internal:5000/ubuntu_python:3.10.6
docker image push registry.devops-db.internal:5000/ubuntu_python:3.10.6
Check in: http://registry.devops-db.internal:5000/v2/ubuntu_python/tags/list
docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
registry.devops-db.internal:5000/ubuntu_python 3.10.6 13c81d4c7f0b 3 days ago 555MB
Test the image locally
docker image rmi ubuntu_python:3.10.6
docker image rmi registry.devops-db.internal:5000/ubuntu_python:3.10.6
docker image pull registry.devops-db.internal:5000/ubuntu_python:3.10.6
docker run -ti --network local-bridge --platform linux/amd64 -v /work/python:/work --name test_python registry.devops-db.internal:5000/ubuntu_python:3.10.6
docker exec -it -u root --privileged test_python /bin/bash
root@50442d575621:/pipeline#