From ea64c2ba98a0a9f1f7eca81cab991214138d08c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Lehmann?= Date: Fri, 5 Sep 2025 22:41:58 +0200 Subject: [PATCH 1/2] Remove xcp-ng-dev-env-create MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Now that the images are easily available on ghcr.io. It makes the completion easier to use for the main tool. Signed-off-by: Gaëtan Lehmann --- .github/workflows/docker.yml | 12 ++++++------ {src/xcp_ng_dev/files => container}/Dockerfile-8.x | 0 {src/xcp_ng_dev/files => container}/Dockerfile-9.x | 0 {src/xcp_ng_dev => container}/build.sh | 4 ++-- .../xcp_ng_dev => container}/files/Alma10-devel.repo | 0 .../files/CentOS-Vault.repo.in | 0 {src/xcp_ng_dev => container}/files/entrypoint.sh | 0 .../xcp_ng_dev => container}/files/init-container.sh | 0 {src/xcp_ng_dev => container}/files/rpmmacros | 0 {src/xcp_ng_dev => container}/files/xcp-ng-8.99.repo | 0 .../files/xcp-ng.repo.7.x.in | 0 .../files/xcp-ng.repo.8.x.in | 0 {src/xcp_ng_dev => container}/files/yum.conf.xs | 0 pyproject.toml | 1 - src/xcp_ng_dev/cli.py | 5 ----- test/test.sh | 2 +- 16 files changed, 9 insertions(+), 15 deletions(-) rename {src/xcp_ng_dev/files => container}/Dockerfile-8.x (100%) rename {src/xcp_ng_dev/files => container}/Dockerfile-9.x (100%) rename {src/xcp_ng_dev => container}/build.sh (95%) rename {src/xcp_ng_dev => container}/files/Alma10-devel.repo (100%) rename {src/xcp_ng_dev => container}/files/CentOS-Vault.repo.in (100%) rename {src/xcp_ng_dev => container}/files/entrypoint.sh (100%) rename {src/xcp_ng_dev => container}/files/init-container.sh (100%) rename {src/xcp_ng_dev => container}/files/rpmmacros (100%) rename {src/xcp_ng_dev => container}/files/xcp-ng-8.99.repo (100%) rename {src/xcp_ng_dev => container}/files/xcp-ng.repo.7.x.in (100%) rename {src/xcp_ng_dev => container}/files/xcp-ng.repo.8.x.in (100%) rename {src/xcp_ng_dev => container}/files/yum.conf.xs (100%) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index bd92760..5684f25 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -22,8 +22,8 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} # Automatically provided by GitHub - uses: docker/build-push-action@v5 # Using v5 for latest features with: - context: ./src/xcp_ng_dev/ - file: ./src/xcp_ng_dev/files/Dockerfile-8.x + context: ./container + file: ./container/Dockerfile-8.x push: ${{ github.ref == 'refs/heads/master' }} tags: ghcr.io/${{ github.repository }}:8.2 cache-from: type=gha,scope=${{ github.ref_name }}-82 # Cache layers to speed up builds @@ -48,8 +48,8 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} # Automatically provided by GitHub - uses: docker/build-push-action@v5 # Using v5 for latest features with: - context: ./src/xcp_ng_dev/ - file: ./src/xcp_ng_dev/files/Dockerfile-8.x + context: ./container + file: ./container/Dockerfile-8.x push: ${{ github.ref == 'refs/heads/master' }} tags: ghcr.io/${{ github.repository }}:8.3 cache-from: type=gha,scope=${{ github.ref_name }}-83 # Cache layers to speed up builds @@ -73,8 +73,8 @@ jobs: # password: ${{ secrets.GITHUB_TOKEN }} # Automatically provided by GitHub # - uses: docker/build-push-action@v5 # Using v5 for latest features # with: - # context: ./src/xcp_ng_dev/ - # file: ./src/xcp_ng_dev/files/Dockerfile-9.x + # context: ./container + # file: ./container/Dockerfile-9.x # platforms: | # linux/amd64/v2 # push: ${{ github.ref == 'refs/heads/master' }} diff --git a/src/xcp_ng_dev/files/Dockerfile-8.x b/container/Dockerfile-8.x similarity index 100% rename from src/xcp_ng_dev/files/Dockerfile-8.x rename to container/Dockerfile-8.x diff --git a/src/xcp_ng_dev/files/Dockerfile-9.x b/container/Dockerfile-9.x similarity index 100% rename from src/xcp_ng_dev/files/Dockerfile-9.x rename to container/Dockerfile-9.x diff --git a/src/xcp_ng_dev/build.sh b/container/build.sh similarity index 95% rename from src/xcp_ng_dev/build.sh rename to container/build.sh index 30f64a8..5e9324c 100755 --- a/src/xcp_ng_dev/build.sh +++ b/container/build.sh @@ -71,12 +71,12 @@ ALMA_VERSION= CENTOS_VERSION= case "$1" in 9.*) - DOCKERFILE=files/Dockerfile-9.x + DOCKERFILE=Dockerfile-9.x ALMA_VERSION=10.0 : ${PLATFORM:=linux/amd64/v2} ;; 8.*) - DOCKERFILE=files/Dockerfile-8.x + DOCKERFILE=Dockerfile-8.x : ${PLATFORM:=linux/amd64} ;; *) diff --git a/src/xcp_ng_dev/files/Alma10-devel.repo b/container/files/Alma10-devel.repo similarity index 100% rename from src/xcp_ng_dev/files/Alma10-devel.repo rename to container/files/Alma10-devel.repo diff --git a/src/xcp_ng_dev/files/CentOS-Vault.repo.in b/container/files/CentOS-Vault.repo.in similarity index 100% rename from src/xcp_ng_dev/files/CentOS-Vault.repo.in rename to container/files/CentOS-Vault.repo.in diff --git a/src/xcp_ng_dev/files/entrypoint.sh b/container/files/entrypoint.sh similarity index 100% rename from src/xcp_ng_dev/files/entrypoint.sh rename to container/files/entrypoint.sh diff --git a/src/xcp_ng_dev/files/init-container.sh b/container/files/init-container.sh similarity index 100% rename from src/xcp_ng_dev/files/init-container.sh rename to container/files/init-container.sh diff --git a/src/xcp_ng_dev/files/rpmmacros b/container/files/rpmmacros similarity index 100% rename from src/xcp_ng_dev/files/rpmmacros rename to container/files/rpmmacros diff --git a/src/xcp_ng_dev/files/xcp-ng-8.99.repo b/container/files/xcp-ng-8.99.repo similarity index 100% rename from src/xcp_ng_dev/files/xcp-ng-8.99.repo rename to container/files/xcp-ng-8.99.repo diff --git a/src/xcp_ng_dev/files/xcp-ng.repo.7.x.in b/container/files/xcp-ng.repo.7.x.in similarity index 100% rename from src/xcp_ng_dev/files/xcp-ng.repo.7.x.in rename to container/files/xcp-ng.repo.7.x.in diff --git a/src/xcp_ng_dev/files/xcp-ng.repo.8.x.in b/container/files/xcp-ng.repo.8.x.in similarity index 100% rename from src/xcp_ng_dev/files/xcp-ng.repo.8.x.in rename to container/files/xcp-ng.repo.8.x.in diff --git a/src/xcp_ng_dev/files/yum.conf.xs b/container/files/yum.conf.xs similarity index 100% rename from src/xcp_ng_dev/files/yum.conf.xs rename to container/files/yum.conf.xs diff --git a/pyproject.toml b/pyproject.toml index 646665b..f9ae8db 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,7 +12,6 @@ dependencies = [ [project.scripts] xcp-ng-dev = "xcp_ng_dev.cli:main" -xcp-ng-dev-env-create = "xcp_ng_dev.cli:build" [project.urls] Homepage = "https://github.com/xcp-ng/xcp-ng-build-env/" diff --git a/src/xcp_ng_dev/cli.py b/src/xcp_ng_dev/cli.py index 642d543..5fd4e9c 100755 --- a/src/xcp_ng_dev/cli.py +++ b/src/xcp_ng_dev/cli.py @@ -252,10 +252,5 @@ def main(): sys.exit(return_code) -def build(): - bargs = [os.path.join(os.path.dirname(__file__), 'build.sh')] + sys.argv[1:] - return_code = subprocess.call(bargs) - sys.exit(return_code) - if __name__ == "__main__": main() diff --git a/test/test.sh b/test/test.sh index 34327fd..9250a36 100755 --- a/test/test.sh +++ b/test/test.sh @@ -4,7 +4,7 @@ set -eux TARGET_XCP_NG_VERSION="8.2" -xcp-ng-dev-env-create "$TARGET_XCP_NG_VERSION" +./container/build.sh "$TARGET_XCP_NG_VERSION" REPOS=xcp-emu-manager From dda80ec9bca1e7302effda5131884dcba6729d14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Lehmann?= Date: Fri, 5 Sep 2025 11:40:05 +0200 Subject: [PATCH 2/2] Add a version in the image tag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit so we can change the interface used to communicate with the container. Using an image tag allows to automatically download the expected image on the developer's computer in case of update. In the future, if we distribute tagged versions of xcp-ng-dev (on pypi for example), we might want to use that version instead. Signed-off-by: Gaëtan Lehmann --- .github/workflows/docker.yml | 9 ++++++--- container/build.sh | 5 ++++- src/xcp_ng_dev/cli.py | 8 +++++++- src/xcp_ng_dev/files/protocol-version.txt | 1 + 4 files changed, 18 insertions(+), 5 deletions(-) create mode 100644 src/xcp_ng_dev/files/protocol-version.txt diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 5684f25..3cd02d6 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -20,12 +20,13 @@ jobs: registry: ghcr.io username: ${{ github.actor }} # Uses the GitHub user/org name that triggered the workflow password: ${{ secrets.GITHUB_TOKEN }} # Automatically provided by GitHub + - run: echo "VERSION=$(cat ./src/xcp_ng_dev/files/protocol-version.txt | tr -d '\n')" >> $GITHUB_ENV - uses: docker/build-push-action@v5 # Using v5 for latest features with: context: ./container file: ./container/Dockerfile-8.x push: ${{ github.ref == 'refs/heads/master' }} - tags: ghcr.io/${{ github.repository }}:8.2 + tags: ghcr.io/${{ github.repository }}:8.2-${{ env.VERSION }} cache-from: type=gha,scope=${{ github.ref_name }}-82 # Cache layers to speed up builds cache-to: type=gha,mode=max,scope=${{ github.ref_name }}-82 # Store layers in cache for future builds build-args: | @@ -46,12 +47,13 @@ jobs: registry: ghcr.io username: ${{ github.actor }} # Uses the GitHub user/org name that triggered the workflow password: ${{ secrets.GITHUB_TOKEN }} # Automatically provided by GitHub + - run: echo "VERSION=$(cat ./src/xcp_ng_dev/files/protocol-version.txt | tr -d '\n')" >> $GITHUB_ENV - uses: docker/build-push-action@v5 # Using v5 for latest features with: context: ./container file: ./container/Dockerfile-8.x push: ${{ github.ref == 'refs/heads/master' }} - tags: ghcr.io/${{ github.repository }}:8.3 + tags: ghcr.io/${{ github.repository }}:8.3-${{ env.VERSION }} cache-from: type=gha,scope=${{ github.ref_name }}-83 # Cache layers to speed up builds cache-to: type=gha,mode=max,scope=${{ github.ref_name }}-83 # Store layers in cache for future builds platforms: | @@ -71,6 +73,7 @@ jobs: # registry: ghcr.io # username: ${{ github.actor }} # Uses the GitHub user/org name that triggered the workflow # password: ${{ secrets.GITHUB_TOKEN }} # Automatically provided by GitHub + # - run: echo "VERSION=$(cat ./src/xcp_ng_dev/files/protocol-version.txt | tr -d '\n')" >> $GITHUB_ENV # - uses: docker/build-push-action@v5 # Using v5 for latest features # with: # context: ./container @@ -78,6 +81,6 @@ jobs: # platforms: | # linux/amd64/v2 # push: ${{ github.ref == 'refs/heads/master' }} - # tags: ghcr.io/${{ github.repository }}:9.0 + # tags: ghcr.io/${{ github.repository }}:9.0-${{ env.VERSION }} # cache-from: type=gha,scope=${{ github.ref_name }}-90 # Cache layers to speed up builds # cache-to: type=gha,mode=max,scope=${{ github.ref_name }}-90 # Store layers in cache for future builds diff --git a/container/build.sh b/container/build.sh index 5e9324c..4abe67b 100755 --- a/container/build.sh +++ b/container/build.sh @@ -85,9 +85,12 @@ case "$1" in ;; esac +version_data=$(cat ../src/xcp_ng_dev/files/protocol-version.txt) +version=$(echo "$version_data" | tr -d '\n') + "$RUNNER" build \ --platform "$PLATFORM" \ - -t ghcr.io/xcp-ng/xcp-ng-build-env:${1} \ + -t ghcr.io/xcp-ng/xcp-ng-build-env:${1}-${version} \ --build-arg XCP_NG_BRANCH=${1} \ --ulimit nofile=1024 \ -f $DOCKERFILE . diff --git a/src/xcp_ng_dev/cli.py b/src/xcp_ng_dev/cli.py index 5fd4e9c..b63c65b 100755 --- a/src/xcp_ng_dev/cli.py +++ b/src/xcp_ng_dev/cli.py @@ -13,6 +13,8 @@ import subprocess import shutil import sys +from pathlib import Path + import argcomplete CONTAINER_PREFIX = "ghcr.io/xcp-ng/xcp-ng-build-env" @@ -37,6 +39,10 @@ def is_podman(runner): return True return False +def read_version(): + with open(Path(__file__).parent / 'files/protocol-version.txt') as f: + return f.read().strip() + def add_common_args(parser): group = parser.add_argument_group("common arguments") group.add_argument('-n', '--no-exit', action='store_true', @@ -235,7 +241,7 @@ def container(args): pass # exec "docker run" - docker_args += [f"{CONTAINER_PREFIX}:{args.container_version}", + docker_args += [f"{CONTAINER_PREFIX}:{args.container_version}-{read_version()}", "/usr/local/bin/init-container.sh"] print("Launching docker with args %s" % docker_args, file=sys.stderr) return subprocess.call(docker_args) diff --git a/src/xcp_ng_dev/files/protocol-version.txt b/src/xcp_ng_dev/files/protocol-version.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/src/xcp_ng_dev/files/protocol-version.txt @@ -0,0 +1 @@ +1