From f170918d8240351e3cd3928c1149f9a3ca505ee6 Mon Sep 17 00:00:00 2001 From: Suraj Deshmukh Date: Thu, 2 May 2024 18:38:41 +0000 Subject: [PATCH] base & tools: Consolidate PowerShell setup Move the powershell module installation from the base Dockerfile to the tools Dockerfile into one RUN command. This will help in reducing the number of layers in the Docker image, thus also reducing the size of the image. Signed-off-by: Suraj Deshmukh --- linux/base.Dockerfile | 9 --------- linux/tools.Dockerfile | 19 +++++++++++++------ 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/linux/base.Dockerfile b/linux/base.Dockerfile index 65673673..382a1735 100644 --- a/linux/base.Dockerfile +++ b/linux/base.Dockerfile @@ -184,12 +184,3 @@ RUN gem install bundler --no-document --clear-sources --force \ ENV GEM_HOME=~/bundle ENV BUNDLE_PATH=~/bundle ENV PATH=$PATH:$GEM_HOME/bin:$BUNDLE_PATH/gems/bin - -# PowerShell telemetry -ENV POWERSHELL_DISTRIBUTION_CHANNEL CloudShell -# don't tell users to upgrade, they can't -ENV POWERSHELL_UPDATECHECK Off - -# Copy and run script to Install powershell modules -COPY ./linux/powershell/ powershell -RUN /usr/bin/pwsh -File ./powershell/setupPowerShell.ps1 -image Base && rm -rf ./powershell diff --git a/linux/tools.Dockerfile b/linux/tools.Dockerfile index a7466c26..1836f945 100644 --- a/linux/tools.Dockerfile +++ b/linux/tools.Dockerfile @@ -59,13 +59,20 @@ RUN mkdir -p /usr/share/ansible/collections/ansible_collections/azure/azcollecti && wget -nv -q -O /usr/share/ansible/collections/ansible_collections/azure/azcollection/requirements.txt https://raw.githubusercontent.com/ansible-collections/azure/dev/requirements.txt \ && /opt/ansible/bin/python -m pip install -r /usr/share/ansible/collections/ansible_collections/azure/azcollection/requirements.txt -# Copy and run script to Install powershell modules and setup Powershell machine profile -COPY ./linux/powershell/PSCloudShellUtility/ /usr/local/share/powershell/Modules/PSCloudShellUtility/ -COPY ./linux/powershell/ powershell -RUN /usr/bin/pwsh -File ./powershell/setupPowerShell.ps1 -image Top && rm -rf ./powershell +# Powershell telemetry +ENV POWERSHELL_DISTRIBUTION_CHANNEL=CloudShell \ + # don't tell users to upgrade, they can't + POWERSHELL_UPDATECHECK=Off -# install powershell warmup script -COPY ./linux/powershell/Invoke-PreparePowerShell.ps1 linux/powershell/Invoke-PreparePowerShell.ps1 +# Copy and run script to install Powershell modules and setup Powershell machine profile +COPY ./linux/powershell/ powershell +RUN /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 # Remove su so users don't have su access by default. RUN rm -f ./linux/Dockerfile && rm -f /bin/su