Skip to content

Commit

Permalink
Dockerfiles: Install az cli and powershell in base and tools image
Browse files Browse the repository at this point in the history
- Tools image overrides, az cli and the powershell installation.
- The install steps check if there is any
  difference between installed and the downloaded
  az cli version. If there is a difference the
  downloaded az cli is installed, powershell is
  also installed as a part of that step.

Signed-off-by: Suraj Deshmukh <suraj.deshmukh@microsoft.com>
  • Loading branch information
surajssd committed Oct 29, 2024
1 parent 2434897 commit 3496268
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 34 deletions.
24 changes: 17 additions & 7 deletions linux/base.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -243,18 +243,26 @@ ENV PATH=~/.local/bin:~/bin:~/.dotnet/tools:$PATH \
POWERSHELL_DISTRIBUTION_CHANNEL=CloudShell \
POWERSHELL_UPDATECHECK=Off

# ------------------------------ Tools Dockerfile ------------------------------
# Copy and run script to install Powershell modules and setup Powershell machine
# profile
COPY ./linux/powershell/ powershell

RUN tdnf clean all && \
# Install latest Azure CLI package. CLI team drops latest (pre-release) package
# here prior to public release We don't support using this location elsewhere -
# it may be removed or updated without notice.
RUN INSTALLED_VERSION=$(az version --output json 2>/dev/null | jq -r '."azure-cli"') && \
wget https://azurecliprod.blob.core.windows.net/cloudshell-release/azure-cli-latest-mariner2.0.rpm && \
# Get the version of the downloaded Azure CLI
DOWNLOADED_VERSION=$(rpm --queryformat="%{VERSION}" -qp ./azure-cli-latest-mariner2.0.rpm) && \
#
# If the installed Azure CLI and the downloaded Azure CLI are different, then
# install the downloaded Azure CLI.
if [ "$DOWNLOADED_VERSION" != "$INSTALLED_VERSION" ]; then \
tdnf clean all && \
tdnf repolist --refresh && \
ACCEPT_EULA=Y tdnf update -y && \
# Install latest Azure CLI package. CLI team drops latest (pre-release) package here prior to public release
# We don't support using this location elsewhere - it may be removed or updated without notice
wget https://azurecliprod.blob.core.windows.net/cloudshell-release/azure-cli-latest-mariner2.0.rpm \
&& tdnf install -y ./azure-cli-latest-mariner2.0.rpm \
&& rm azure-cli-latest-mariner2.0.rpm && \
tdnf install -y ./azure-cli-latest-mariner2.0.rpm && \
tdnf clean all && \
rm -rf /var/cache/tdnf/* && \
#
Expand All @@ -272,5 +280,7 @@ RUN tdnf clean all && \
/usr/bin/pwsh -File ./powershell/setupPowerShell.ps1 -image Top && \
# Install Powershell warmup script
mkdir -p linux/powershell && \
cp powershell/Invoke-PreparePowerShell.ps1 linux/powershell/Invoke-PreparePowerShell.ps1 && \
cp powershell/Invoke-PreparePowerShell.ps1 linux/powershell/Invoke-PreparePowerShell.ps1; \
fi && \
rm azure-cli-latest-mariner2.0.rpm && \
rm -rf ./powershell
64 changes: 37 additions & 27 deletions linux/tools.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,44 @@ FROM ${IMAGE_LOCATION}

LABEL org.opencontainers.image.source="https://github.com/Azure/CloudShell"

# ---------------------- Installation same as base image ----------------------
# Copy and run script to install Powershell modules and setup Powershell machine
# profile
COPY ./linux/powershell/ powershell

RUN tdnf clean all && \
tdnf repolist --refresh && \
ACCEPT_EULA=Y tdnf update -y && \
# Install latest Azure CLI package. CLI team drops latest (pre-release) package here prior to public release
# We don't support using this location elsewhere - it may be removed or updated without notice
wget https://azurecliprod.blob.core.windows.net/cloudshell-release/azure-cli-latest-mariner2.0.rpm \
&& tdnf install -y ./azure-cli-latest-mariner2.0.rpm \
&& rm azure-cli-latest-mariner2.0.rpm && \
tdnf clean all && \
rm -rf /var/cache/tdnf/* && \
#
# Install any Azure CLI extensions that should be included by default.
az extension add --system --name ai-examples -y && \
az extension add --system --name ssh -y && \
az extension add --system --name ml -y && \
#
# Install kubectl
az aks install-cli && \
#
# Powershell installation and setup
/usr/bin/pwsh -File ./powershell/setupPowerShell.ps1 -image Base && \
cp -r ./powershell/PSCloudShellUtility /usr/local/share/powershell/Modules/PSCloudShellUtility/ && \
/usr/bin/pwsh -File ./powershell/setupPowerShell.ps1 -image Top && \
# Install Powershell warmup script
mkdir -p linux/powershell && \
cp powershell/Invoke-PreparePowerShell.ps1 linux/powershell/Invoke-PreparePowerShell.ps1 && \
rm -rf ./powershell
# Install latest Azure CLI package. CLI team drops latest (pre-release) package
# here prior to public release We don't support using this location elsewhere -
# it may be removed or updated without notice.
RUN INSTALLED_VERSION=$(az version --output json 2>/dev/null | jq -r '."azure-cli"') && \
wget https://azurecliprod.blob.core.windows.net/cloudshell-release/azure-cli-latest-mariner2.0.rpm && \
# Get the version of the downloaded Azure CLI
DOWNLOADED_VERSION=$(rpm --queryformat="%{VERSION}" -qp ./azure-cli-latest-mariner2.0.rpm) && \
#
# If the installed Azure CLI and the downloaded Azure CLI are different, then
# install the downloaded Azure CLI.
if [ "$DOWNLOADED_VERSION" != "$INSTALLED_VERSION" ]; then \
tdnf clean all && \
tdnf repolist --refresh && \
ACCEPT_EULA=Y tdnf update -y && \
tdnf install -y ./azure-cli-latest-mariner2.0.rpm && \
tdnf clean all && \
rm -rf /var/cache/tdnf/* && \
#
# Install any Azure CLI extensions that should be included by default.
az extension add --system --name ai-examples -y && \
az extension add --system --name ssh -y && \
az extension add --system --name ml -y && \
#
# Install kubectl
az aks install-cli && \
#
# Powershell installation and setup
/usr/bin/pwsh -File ./powershell/setupPowerShell.ps1 -image Base && \
cp -r ./powershell/PSCloudShellUtility /usr/local/share/powershell/Modules/PSCloudShellUtility/ && \
/usr/bin/pwsh -File ./powershell/setupPowerShell.ps1 -image Top && \
# Install Powershell warmup script
mkdir -p linux/powershell && \
cp powershell/Invoke-PreparePowerShell.ps1 linux/powershell/Invoke-PreparePowerShell.ps1; \
fi && \
rm azure-cli-latest-mariner2.0.rpm && \
rm -rf ./powershell

0 comments on commit 3496268

Please sign in to comment.