Skip to content
Merged
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
27 changes: 21 additions & 6 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we unpin the last version?

Suggested change
image: registry.access.redhat.com/ubi9/ubi:9.0.0
image: registry.access.redhat.com/ubi9/ubi:9.0

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

9.0 returns 404.

Copy link
Member

@jiasli jiasli Aug 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed I got failure:

> docker run -it --rm registry.access.redhat.com/ubi9/ubi:9.0
Unable to find image 'registry.access.redhat.com/ubi9/ubi:9.0' locally
docker: Error response from daemon: error parsing HTTP 404 response body: invalid character 'N' looking for beginning of value: "Not found\n".
See 'docker run --help'.

Too much inconsistency! 😣

artifact: rpm-ubi9
python_package: python3.9
Copy link
Member

@jiasli jiasli Aug 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

python39 in RHEL 8 becames python3.9 in RHEL 9. It's bad design for RHEL 9 to introduce this inconsistency.

Fedora35:
image: fedora
tag: 35
dockerfile: fedora
image: fedora:35
Copy link
Member

@jiasli jiasli Aug 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this change! Much clearer and less cumbersome!

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'
Expand Down Expand Up @@ -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
Expand Down
11 changes: 6 additions & 5 deletions scripts/release/rpm/fedora.dockerfile
Original file line number Diff line number Diff line change
@@ -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 && \
Expand Down
24 changes: 14 additions & 10 deletions scripts/release/rpm/pipeline.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,37 @@ 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`

# Create a container image that includes the source code and a built RPM using this file.
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}
Expand Down
31 changes: 31 additions & 0 deletions scripts/release/rpm/ubi.dockerfile
Original file line number Diff line number Diff line change
@@ -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
28 changes: 0 additions & 28 deletions scripts/release/rpm/ubi8.dockerfile

This file was deleted.