From 040d316f54c80074a5ed9d4516b56dc3fa04a223 Mon Sep 17 00:00:00 2001 From: Yuming Zhu Date: Oct 21 2024 13:53:36 +0000 Subject: [PATCH 1/3] update Dockerfiles for devcontainer --- diff --git a/devtools/containers/Dockerfile.centos7 b/devtools/containers/Dockerfile.centos7 index 35ef358..6f9776f 100644 --- a/devtools/containers/Dockerfile.centos7 +++ b/devtools/containers/Dockerfile.centos7 @@ -1,5 +1,9 @@ FROM quay.io/centos/centos:7 +ARG EXTRA_PKGS RUN \ + sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/CentOS-*.repo && \ + sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/CentOS-*.repo && \ + sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/CentOS-*.repo && \ yum -y update && \ yum install -y \ dnf \ @@ -15,7 +19,10 @@ RUN \ yum install -y \ python-defusedxml \ python-pip \ - python-psycopg2 && \ + python-psycopg2 \ + ${EXTRA_PKGS} && \ yum clean all && \ - pip install -U 'pip==9.0.1' && \ + pip install -U 'pip==9.0.3' \ + --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host files.pythonhosted.org \ + --upgrade && \ pip install -U tox diff --git a/devtools/containers/Dockerfile.centos8 b/devtools/containers/Dockerfile.centos8 index 5962967..0e97da6 100644 --- a/devtools/containers/Dockerfile.centos8 +++ b/devtools/containers/Dockerfile.centos8 @@ -1,5 +1,5 @@ FROM quay.io/centos/centos:stream8 - +ARG EXTRA_PKGS RUN \ dnf -y update --nodocs --setopt=install_weak_deps=False && \ dnf install -y --nodocs --setopt=install_weak_deps=False epel-release && \ @@ -11,5 +11,5 @@ RUN \ python3-devel \ python3-librepo \ python3-tox \ - rpm-build && \ + ${EXTRA_PKGS} && \ dnf clean all diff --git a/devtools/containers/Dockerfile.centos9 b/devtools/containers/Dockerfile.centos9 index 7135a64..d659ffe 100644 --- a/devtools/containers/Dockerfile.centos9 +++ b/devtools/containers/Dockerfile.centos9 @@ -1,5 +1,5 @@ FROM quay.io/centos/centos:stream9 - +ARG EXTRA_PKGS RUN \ dnf -y update --nodocs --setopt=install_weak_deps=False && \ dnf install -y --nodocs --setopt=install_weak_deps=False epel-release && \ @@ -11,5 +11,5 @@ RUN \ python3-devel \ python3-librepo \ python3-tox \ - rpm-build && \ + ${EXTRA_PKGS} && \ dnf clean all diff --git a/devtools/containers/Dockerfile.f39 b/devtools/containers/Dockerfile.f39 index fdd84c7..d83a96f 100644 --- a/devtools/containers/Dockerfile.f39 +++ b/devtools/containers/Dockerfile.f39 @@ -1,4 +1,5 @@ FROM registry.fedoraproject.org/fedora:39 +ARG EXTRA_PKGS RUN \ dnf -y update --nodocs --setopt=install_weak_deps=False && \ dnf install -y --nodocs --setopt=install_weak_deps=False \ @@ -9,5 +10,6 @@ RUN \ python3-devel \ python3-librepo \ python3-tox \ - rpm-build && \ + rpm-build \ + ${EXTRA_PKGS} && \ dnf clean all diff --git a/devtools/containers/Dockerfile.rawhide b/devtools/containers/Dockerfile.rawhide index 3f907c6..102f1f2 100644 --- a/devtools/containers/Dockerfile.rawhide +++ b/devtools/containers/Dockerfile.rawhide @@ -1,4 +1,5 @@ FROM registry.fedoraproject.org/fedora:rawhide +ARG EXTRA_PKGS RUN \ dnf -y update --nodocs --setopt=install_weak_deps=False && \ dnf install -y --nodocs --setopt=install_weak_deps=False \ @@ -9,5 +10,6 @@ RUN \ python3-devel \ python3-librepo \ python3-tox \ - rpm-build && \ + rpm-build \ + ${EXTRA_PKGS} && \ dnf clean all diff --git a/devtools/containers/README.md b/devtools/containers/README.md index dabb0d0..59c0df4 100644 --- a/devtools/containers/README.md +++ b/devtools/containers/README.md @@ -27,10 +27,14 @@ Or CentOS with py3 as an example: Or CentOS with py2 as an example: - docker build -t koji_test_centos:7 --no-cache -f Dockerfile.centos8 + docker build -t koji_test_centos:7 --no-cache -f Dockerfile.centos7 docker run --rm -v $PWD:/koji --name koji_test koji_test_centos:7 bash -c "cd /koji && tox -e py2" When running with Podman and SELinux enabled, use the "--security-opt label=disable" option: podman run --rm -v $PWD:/koji --security-opt label=disable --name koji_test koji_test_fedora:39 bash -c "cd /koji && ls -l /koji && tox -e flake8,py3,bandit" + +One build argument - `EXTRA_PKGS` is provided to install custom packages while building images (for CentOS* and Fedora 39+), like: + + docker build --build-arg EXTRA_PKGS="git make" -t koji_test_centos:7 --no-cache -f Dockerfile.centos7 From ce7a8ddde0a5bd822e677899ef257f4aa6f4c1ae Mon Sep 17 00:00:00 2001 From: Yuming Zhu Date: Oct 21 2024 13:53:56 +0000 Subject: [PATCH 2/3] vscode devcontainers --- diff --git a/.devcontainer/on_create.sh b/.devcontainer/on_create.sh new file mode 100755 index 0000000..62b8e54 --- /dev/null +++ b/.devcontainer/on_create.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +set -e + +PIP_CMD=${PIP_CMD:=pip3} + +echo ". /usr/share/git-core/contrib/completion/git-prompt.sh" >> ~/.bashrc +echo "export PS1='[\[\e[34m\]\W\[\e[35m\]\$(__git_ps1 \" %s\")\[\e[00m\]]$\[\e[00m\] '" >> ~/.bashrc + +$PIP_CMD install -r requirements.txt diff --git a/.devcontainer/python2/devcontainer.json b/.devcontainer/python2/devcontainer.json new file mode 100644 index 0000000..82c670d --- /dev/null +++ b/.devcontainer/python2/devcontainer.json @@ -0,0 +1,29 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/python +{ + "name": "centos7-python2-devel", + + // "image": "quay.io/centos/centos:7", + "build": { + "dockerfile": "../../devtools/containers/Dockerfile.centos7", + "args": { + "EXTRA_PKGS": "git vim make" + } + }, + + "shutdownAction": "stopContainer", + + "postCreateCommand": "PIP_CMD=pip bash .devcontainer/on_create.sh", + + "remoteUser": "root", + + "customizations": { + "vscode": { + "extensions": [ + "ms-python.python", + "ms-python.vscode-pylance", + "ms-python.isort" + ] + } + } +} diff --git a/.devcontainer/python3/devcontainer.json b/.devcontainer/python3/devcontainer.json new file mode 100644 index 0000000..81a8b08 --- /dev/null +++ b/.devcontainer/python3/devcontainer.json @@ -0,0 +1,28 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/python +{ + "name": "fedora-python3-devel", + // "image": "quay.io/fedora/fedora:latest", + "build": { + "dockerfile": "../../devtools/containers/Dockerfile.f39", + "args": { + "EXTRA_PKGS": "git vim make python3-pip" + } + }, + + "shutdownAction": "stopContainer", + + "postCreateCommand": "PIP_CMD=pip3 bash .devcontainer/on_create.sh", + + "remoteUser": "root", + + "customizations": { + "vscode": { + "extensions": [ + "ms-python.python", + "ms-python.vscode-pylance", + "ms-python.isort" + ] + } + } +} From d874cf4c99c47cb4e0424bd59bca064d638b4232 Mon Sep 17 00:00:00 2001 From: Yuming Zhu Date: Oct 23 2024 08:40:38 +0000 Subject: [PATCH 3/3] add bash-completion and docker vscode plugin --- diff --git a/.devcontainer/python2/devcontainer.json b/.devcontainer/python2/devcontainer.json index 82c670d..d597b9d 100644 --- a/.devcontainer/python2/devcontainer.json +++ b/.devcontainer/python2/devcontainer.json @@ -7,7 +7,7 @@ "build": { "dockerfile": "../../devtools/containers/Dockerfile.centos7", "args": { - "EXTRA_PKGS": "git vim make" + "EXTRA_PKGS": "git vim make bash-completion" } }, @@ -22,7 +22,8 @@ "extensions": [ "ms-python.python", "ms-python.vscode-pylance", - "ms-python.isort" + "ms-python.isort", + "ms-azuretools.vscode-docker" ] } } diff --git a/.devcontainer/python3/devcontainer.json b/.devcontainer/python3/devcontainer.json index 81a8b08..b8bd14c 100644 --- a/.devcontainer/python3/devcontainer.json +++ b/.devcontainer/python3/devcontainer.json @@ -6,7 +6,7 @@ "build": { "dockerfile": "../../devtools/containers/Dockerfile.f39", "args": { - "EXTRA_PKGS": "git vim make python3-pip" + "EXTRA_PKGS": "git vim make bash-completion python3-pip" } }, @@ -21,7 +21,8 @@ "extensions": [ "ms-python.python", "ms-python.vscode-pylance", - "ms-python.isort" + "ms-python.isort", + "ms-azuretools.vscode-docker" ] } }