diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 12e64961b96..6ca010e74a7 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -637,17 +637,25 @@ jobs: strategy: matrix: Red Hat Universal Base Image 8: - image: ubi8 - tag: 8.4 + dockerfile: ubi + image: registry.access.redhat.com/ubi8/ubi:8.4 artifact: rpm-ubi8 + python_package: python39 + Red Hat Universal Base Image 9: + dockerfile: ubi + image: registry.access.redhat.com/ubi9/ubi:9.0.0 + artifact: rpm-ubi9 + python_package: python3.9 Fedora35: - image: fedora - tag: 35 + dockerfile: fedora + image: fedora:35 artifact: rpm-fedora35 + python_package: python3 Fedora36: - image: fedora - tag: 36 + dockerfile: fedora + image: fedora:36 artifact: rpm-fedora36 + python_package: python3 steps: - task: Bash@3 displayName: 'Build Rpm Package' @@ -684,6 +692,13 @@ jobs: python_package: python39 python_cmd: python3.9 pip_cmd: pip3.9 + Red Hat Universal Base Image 9: + artifact: rpm-ubi9 + distro: el9 + image: registry.access.redhat.com/ubi9/ubi:9.0.0 + python_package: python3.9 + python_cmd: python3.9 + pip_cmd: pip3.9 Fedora35: artifact: rpm-fedora35 distro: fc35 diff --git a/scripts/release/rpm/fedora.dockerfile b/scripts/release/rpm/fedora.dockerfile index 531216f0d2e..ea8b6c45cae 100644 --- a/scripts/release/rpm/fedora.dockerfile +++ b/scripts/release/rpm/fedora.dockerfile @@ -1,21 +1,22 @@ -ARG tag=35 +ARG image=fedora:35 -FROM fedora:${tag} AS build-env +FROM ${image} AS build-env ARG cli_version=dev +ARG python_package=python3 RUN dnf update -y -RUN dnf install -y wget rpm-build gcc libffi-devel python3-devel openssl-devel make bash coreutils diffutils patch dos2unix perl +RUN dnf install -y wget rpm-build gcc libffi-devel ${python_package}-devel openssl-devel make bash coreutils diffutils patch dos2unix perl WORKDIR /azure-cli COPY . . RUN dos2unix ./scripts/release/rpm/azure-cli.spec && \ - REPO_PATH=$(pwd) CLI_VERSION=$cli_version PYTHON_PACKAGE=python3 PYTHON_CMD=python3 \ + REPO_PATH=$(pwd) CLI_VERSION=$cli_version PYTHON_PACKAGE=$python_package PYTHON_CMD=python3 \ rpmbuild -v -bb --clean scripts/release/rpm/azure-cli.spec && \ cp /root/rpmbuild/RPMS/x86_64/azure-cli-${cli_version}-1.*.x86_64.rpm /azure-cli-dev.rpm -FROM fedora:${tag} AS execution-env +FROM ${image} AS execution-env COPY --from=build-env /azure-cli-dev.rpm ./ RUN rpm -i ./azure-cli-dev.rpm && \ diff --git a/scripts/release/rpm/pipeline.sh b/scripts/release/rpm/pipeline.sh index d1d6ec84331..106af0ad627 100755 --- a/scripts/release/rpm/pipeline.sh +++ b/scripts/release/rpm/pipeline.sh @@ -6,10 +6,12 @@ set -exv : "${BUILD_STAGINGDIRECTORY:?BUILD_STAGINGDIRECTORY environment variable not set.}" -# IMAGE should be one of 'centos7', 'ubi8' or 'fedora' +# DOCKERFILE should be one of 'ubi' or 'fedora' +: "${DOCKERFILE:?DOCKERFILE environment variable not set.}" +# IMAGE should be RHEL or Fedora image url : "${IMAGE:?IMAGE environment variable not set.}" -# TAG should be 'centos7', '8.4' or Fedora version number -: "${TAG:?TAG environment variable not set.}" +# PYTHON_PACKAGE should be python package name +: "${PYTHON_PACKAGE:?PYTHON_PACKAGE environment variable not set.}" CLI_VERSION=`cat src/azure-cli/azure/cli/__main__.py | grep __version__ | sed s/' '//g | sed s/'__version__='// | sed s/\"//g` @@ -17,22 +19,24 @@ CLI_VERSION=`cat src/azure-cli/azure/cli/__main__.py | grep __version__ | sed s/ docker build \ --target build-env \ --build-arg cli_version=${CLI_VERSION} \ - --build-arg tag=${TAG} \ - -f ./scripts/release/rpm/${IMAGE}.dockerfile \ - -t azure/azure-cli:${IMAGE}-builder \ + --build-arg image=${IMAGE} \ + --build-arg python_package=${PYTHON_PACKAGE} \ + -f ./scripts/release/rpm/${DOCKERFILE}.dockerfile \ + -t azure/azure-cli:${DOCKERFILE}-builder \ . # Continue the previous build, and create a container that has the current azure-cli build but not the source code. docker build \ --build-arg cli_version=${CLI_VERSION} \ - --build-arg tag=${TAG} \ - -f ./scripts/release/rpm/${IMAGE}.dockerfile \ - -t azure/azure-cli:${IMAGE} \ + --build-arg image=${IMAGE} \ + --build-arg python_package=${PYTHON_PACKAGE} \ + -f ./scripts/release/rpm/${DOCKERFILE}.dockerfile \ + -t azure/azure-cli:${DOCKERFILE} \ . # Extract the built RPM so that it can be distributed independently. # The RPM file looks like azure-cli-2.32.0-1.el7.x86_64.rpm -id=$(docker create azure/azure-cli:${IMAGE}-builder) +id=$(docker create azure/azure-cli:${DOCKERFILE}-builder) # https://docs.docker.com/engine/reference/commandline/cp/ # Append /. so that the x86_64 folder's content is copied, instead of x86_64 folder itself. docker cp $id:/root/rpmbuild/RPMS/x86_64/. ${BUILD_STAGINGDIRECTORY} diff --git a/scripts/release/rpm/ubi.dockerfile b/scripts/release/rpm/ubi.dockerfile new file mode 100644 index 00000000000..b1ecef72fad --- /dev/null +++ b/scripts/release/rpm/ubi.dockerfile @@ -0,0 +1,31 @@ +# Red Hat Universal Base Image 8: https://catalog.redhat.com/software/containers/ubi8/ubi/5c359854d70cc534b3a3784e +# Red Hat Universal Base Image 9: https://catalog.redhat.com/software/containers/ubi9/ubi/615bcf606feffc5384e8452e + +ARG image=registry.access.redhat.com/ubi8/ubi:8.4 + +FROM ${image} AS build-env +ARG cli_version=dev +ARG python_package=python39 + +RUN yum update -y +RUN yum install -y wget rpm-build gcc libffi-devel ${python_package}-devel openssl-devel make bash diffutils patch dos2unix perl + +WORKDIR /azure-cli + +COPY . . + +# RHEL 8's 'python3' is Python 3.6. RHEL 9's 'python3' is Python 3.9. +# We have to explicitly specify 'python39' to install Python 3.9. +RUN dos2unix ./scripts/release/rpm/azure-cli.spec && \ + REPO_PATH=$(pwd) CLI_VERSION=$cli_version PYTHON_PACKAGE=$python_package PYTHON_CMD=python3.9 \ + rpmbuild -v -bb --clean scripts/release/rpm/azure-cli.spec && \ + cp /root/rpmbuild/RPMS/x86_64/azure-cli-${cli_version}-1.*.x86_64.rpm /azure-cli-dev.rpm + +FROM ${image} AS execution-env + +RUN yum update -y +RUN yum install -y python39 + +COPY --from=build-env /azure-cli-dev.rpm ./ +RUN rpm -i ./azure-cli-dev.rpm && \ + az --version diff --git a/scripts/release/rpm/ubi8.dockerfile b/scripts/release/rpm/ubi8.dockerfile deleted file mode 100644 index e53fec41d49..00000000000 --- a/scripts/release/rpm/ubi8.dockerfile +++ /dev/null @@ -1,28 +0,0 @@ -# Red Hat Universal Base Image 8: https://catalog.redhat.com/software/containers/ubi8/ubi/5c359854d70cc534b3a3784e - -ARG tag=8.4 - -FROM registry.access.redhat.com/ubi8/ubi:${tag} AS build-env -ARG cli_version=dev - -RUN yum update -y -RUN yum install -y wget rpm-build gcc libffi-devel python39-devel openssl-devel make bash diffutils patch dos2unix perl - -WORKDIR /azure-cli - -COPY . . - -# RHEL's 'python3' is Python 3.6. We have to explicitly specify 'python39' to install Python 3.9. -RUN dos2unix ./scripts/release/rpm/azure-cli.spec && \ - REPO_PATH=$(pwd) CLI_VERSION=$cli_version PYTHON_PACKAGE=python39 PYTHON_CMD=python3.9 \ - rpmbuild -v -bb --clean scripts/release/rpm/azure-cli.spec && \ - cp /root/rpmbuild/RPMS/x86_64/azure-cli-${cli_version}-1.*.x86_64.rpm /azure-cli-dev.rpm - -FROM registry.access.redhat.com/ubi8/ubi:${tag} AS execution-env - -RUN yum update -y -RUN yum install -y python39 - -COPY --from=build-env /azure-cli-dev.rpm ./ -RUN rpm -i ./azure-cli-dev.rpm && \ - az --version