Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: ./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
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: |
Expand All @@ -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: ./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
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: |
Expand All @@ -71,13 +73,14 @@ 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: ./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' }}
# 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
File renamed without changes.
File renamed without changes.
9 changes: 6 additions & 3 deletions src/xcp_ng_dev/build.sh → container/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}
;;
*)
Expand All @@ -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 .
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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/"
Expand Down
13 changes: 7 additions & 6 deletions src/xcp_ng_dev/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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',
Expand Down Expand Up @@ -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)
Expand All @@ -252,10 +258,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()
1 change: 1 addition & 0 deletions src/xcp_ng_dev/files/protocol-version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1
2 changes: 1 addition & 1 deletion test/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down