Skip to content

Commit 3496268

Browse files
committed
Dockerfiles: Install az cli and powershell in base and tools image
- 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>
1 parent 2434897 commit 3496268

File tree

2 files changed

+54
-34
lines changed

2 files changed

+54
-34
lines changed

linux/base.Dockerfile

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -243,18 +243,26 @@ ENV PATH=~/.local/bin:~/bin:~/.dotnet/tools:$PATH \
243243
POWERSHELL_DISTRIBUTION_CHANNEL=CloudShell \
244244
POWERSHELL_UPDATECHECK=Off
245245

246+
# ------------------------------ Tools Dockerfile ------------------------------
246247
# Copy and run script to install Powershell modules and setup Powershell machine
247248
# profile
248249
COPY ./linux/powershell/ powershell
249250

250-
RUN tdnf clean all && \
251+
# Install latest Azure CLI package. CLI team drops latest (pre-release) package
252+
# here prior to public release We don't support using this location elsewhere -
253+
# it may be removed or updated without notice.
254+
RUN INSTALLED_VERSION=$(az version --output json 2>/dev/null | jq -r '."azure-cli"') && \
255+
wget https://azurecliprod.blob.core.windows.net/cloudshell-release/azure-cli-latest-mariner2.0.rpm && \
256+
# Get the version of the downloaded Azure CLI
257+
DOWNLOADED_VERSION=$(rpm --queryformat="%{VERSION}" -qp ./azure-cli-latest-mariner2.0.rpm) && \
258+
#
259+
# If the installed Azure CLI and the downloaded Azure CLI are different, then
260+
# install the downloaded Azure CLI.
261+
if [ "$DOWNLOADED_VERSION" != "$INSTALLED_VERSION" ]; then \
262+
tdnf clean all && \
251263
tdnf repolist --refresh && \
252264
ACCEPT_EULA=Y tdnf update -y && \
253-
# Install latest Azure CLI package. CLI team drops latest (pre-release) package here prior to public release
254-
# We don't support using this location elsewhere - it may be removed or updated without notice
255-
wget https://azurecliprod.blob.core.windows.net/cloudshell-release/azure-cli-latest-mariner2.0.rpm \
256-
&& tdnf install -y ./azure-cli-latest-mariner2.0.rpm \
257-
&& rm azure-cli-latest-mariner2.0.rpm && \
265+
tdnf install -y ./azure-cli-latest-mariner2.0.rpm && \
258266
tdnf clean all && \
259267
rm -rf /var/cache/tdnf/* && \
260268
#
@@ -272,5 +280,7 @@ RUN tdnf clean all && \
272280
/usr/bin/pwsh -File ./powershell/setupPowerShell.ps1 -image Top && \
273281
# Install Powershell warmup script
274282
mkdir -p linux/powershell && \
275-
cp powershell/Invoke-PreparePowerShell.ps1 linux/powershell/Invoke-PreparePowerShell.ps1 && \
283+
cp powershell/Invoke-PreparePowerShell.ps1 linux/powershell/Invoke-PreparePowerShell.ps1; \
284+
fi && \
285+
rm azure-cli-latest-mariner2.0.rpm && \
276286
rm -rf ./powershell

linux/tools.Dockerfile

Lines changed: 37 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,34 +10,44 @@ FROM ${IMAGE_LOCATION}
1010

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

13+
# ---------------------- Installation same as base image ----------------------
1314
# Copy and run script to install Powershell modules and setup Powershell machine
1415
# profile
1516
COPY ./linux/powershell/ powershell
1617

17-
RUN tdnf clean all && \
18-
tdnf repolist --refresh && \
19-
ACCEPT_EULA=Y tdnf update -y && \
20-
# Install latest Azure CLI package. CLI team drops latest (pre-release) package here prior to public release
21-
# We don't support using this location elsewhere - it may be removed or updated without notice
22-
wget https://azurecliprod.blob.core.windows.net/cloudshell-release/azure-cli-latest-mariner2.0.rpm \
23-
&& tdnf install -y ./azure-cli-latest-mariner2.0.rpm \
24-
&& rm azure-cli-latest-mariner2.0.rpm && \
25-
tdnf clean all && \
26-
rm -rf /var/cache/tdnf/* && \
27-
#
28-
# Install any Azure CLI extensions that should be included by default.
29-
az extension add --system --name ai-examples -y && \
30-
az extension add --system --name ssh -y && \
31-
az extension add --system --name ml -y && \
32-
#
33-
# Install kubectl
34-
az aks install-cli && \
35-
#
36-
# Powershell installation and setup
37-
/usr/bin/pwsh -File ./powershell/setupPowerShell.ps1 -image Base && \
38-
cp -r ./powershell/PSCloudShellUtility /usr/local/share/powershell/Modules/PSCloudShellUtility/ && \
39-
/usr/bin/pwsh -File ./powershell/setupPowerShell.ps1 -image Top && \
40-
# Install Powershell warmup script
41-
mkdir -p linux/powershell && \
42-
cp powershell/Invoke-PreparePowerShell.ps1 linux/powershell/Invoke-PreparePowerShell.ps1 && \
43-
rm -rf ./powershell
18+
# Install latest Azure CLI package. CLI team drops latest (pre-release) package
19+
# here prior to public release We don't support using this location elsewhere -
20+
# it may be removed or updated without notice.
21+
RUN INSTALLED_VERSION=$(az version --output json 2>/dev/null | jq -r '."azure-cli"') && \
22+
wget https://azurecliprod.blob.core.windows.net/cloudshell-release/azure-cli-latest-mariner2.0.rpm && \
23+
# Get the version of the downloaded Azure CLI
24+
DOWNLOADED_VERSION=$(rpm --queryformat="%{VERSION}" -qp ./azure-cli-latest-mariner2.0.rpm) && \
25+
#
26+
# If the installed Azure CLI and the downloaded Azure CLI are different, then
27+
# install the downloaded Azure CLI.
28+
if [ "$DOWNLOADED_VERSION" != "$INSTALLED_VERSION" ]; then \
29+
tdnf clean all && \
30+
tdnf repolist --refresh && \
31+
ACCEPT_EULA=Y tdnf update -y && \
32+
tdnf install -y ./azure-cli-latest-mariner2.0.rpm && \
33+
tdnf clean all && \
34+
rm -rf /var/cache/tdnf/* && \
35+
#
36+
# Install any Azure CLI extensions that should be included by default.
37+
az extension add --system --name ai-examples -y && \
38+
az extension add --system --name ssh -y && \
39+
az extension add --system --name ml -y && \
40+
#
41+
# Install kubectl
42+
az aks install-cli && \
43+
#
44+
# Powershell installation and setup
45+
/usr/bin/pwsh -File ./powershell/setupPowerShell.ps1 -image Base && \
46+
cp -r ./powershell/PSCloudShellUtility /usr/local/share/powershell/Modules/PSCloudShellUtility/ && \
47+
/usr/bin/pwsh -File ./powershell/setupPowerShell.ps1 -image Top && \
48+
# Install Powershell warmup script
49+
mkdir -p linux/powershell && \
50+
cp powershell/Invoke-PreparePowerShell.ps1 linux/powershell/Invoke-PreparePowerShell.ps1; \
51+
fi && \
52+
rm azure-cli-latest-mariner2.0.rpm && \
53+
rm -rf ./powershell

0 commit comments

Comments
 (0)