#4247 vscode devcontainer support
Opened 3 months ago by julian8628. Modified 3 months ago
julian8628/koji vscode-devcontainer  into  master

@@ -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

This depends on Issue #4244

@@ -0,0 +1,30 @@ 

+ // 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 bash-completion"

+ 		}

+ 	},

+ 

+ 	"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",

+ 				"ms-azuretools.vscode-docker"

+ 			]

+ 		}

+ 	}

+ }

@@ -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": "fedora-python3-devel",

+ 	// "image": "quay.io/fedora/fedora:latest",

+ 	"build": {

+ 		"dockerfile": "../../devtools/containers/Dockerfile.f39",

+ 		"args": {

+ 			"EXTRA_PKGS": "git vim make bash-completion 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",

+ 				"ms-azuretools.vscode-docker"

+ 			]

+ 		}

+ 	}

+ }

@@ -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 @@ 

    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

@@ -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 @@ 

    python3-devel \

    python3-librepo \

    python3-tox \

-   rpm-build && \

+   ${EXTRA_PKGS} && \

    dnf clean all

@@ -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 @@ 

    python3-devel \

    python3-librepo \

    python3-tox \

-   rpm-build && \

+   ${EXTRA_PKGS} && \

    dnf clean all

@@ -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 @@ 

    python3-devel \

    python3-librepo \

    python3-tox \

-   rpm-build && \

+   rpm-build \

+   ${EXTRA_PKGS} && \

    dnf clean all

@@ -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 @@ 

    python3-devel \

    python3-librepo \

    python3-tox \

-   rpm-build && \

+   rpm-build \

+   ${EXTRA_PKGS} && \

    dnf clean all

@@ -27,10 +27,14 @@ 

  

  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