From 9e3b260ce54a5bbe0434e5abb12a075c8d8409d2 Mon Sep 17 00:00:00 2001 From: NanxiangLiu <33285578+Nickcandy@users.noreply.github.com> Date: Mon, 23 Sep 2024 21:21:20 +0800 Subject: [PATCH] update docker file (#26153) --- docker/Dockerfile-alpine-3.17 | 5 +++- docker/Dockerfile-debian-11 | 50 ------------------------------- docker/Dockerfile-debian-12 | 5 +++- docker/Dockerfile-mariner-2 | 5 +++- docker/Dockerfile-mariner-2-arm64 | 5 +++- docker/Dockerfile-ubi-8 | 5 +++- docker/Dockerfile-ubi-9 | 5 +++- docker/Dockerfile-ubuntu-20.04 | 5 +++- docker/Dockerfile-ubuntu-22.04 | 3 ++ 9 files changed, 31 insertions(+), 57 deletions(-) delete mode 100644 docker/Dockerfile-debian-11 diff --git a/docker/Dockerfile-alpine-3.17 b/docker/Dockerfile-alpine-3.17 index 950b3f259196..d685493110e5 100644 --- a/docker/Dockerfile-alpine-3.17 +++ b/docker/Dockerfile-alpine-3.17 @@ -1,4 +1,5 @@ FROM mcr.microsoft.com/powershell:alpine-3.17 +RUN apk update && apk upgrade --no-cache ARG REPOSITORY=PSGallery ARG MODULE=Az @@ -36,7 +37,9 @@ RUN if [ "${LATEST}" = True ] ; then \ pwsh -Command Invoke-WebRequest -uri ${BLOB_URL} -OutFile latest.tar.gz && \ mkdir latest && \ tar -zxvf ./latest.tar.gz -C ./latest && \ - pwsh -Command ./latest/InstallModule.ps1 -Scope AllUsers;\ + pwsh -Command ./latest/InstallModule.ps1 -Scope AllUsers &&\ + rm -fr latest &&\ + rm -f latest.tar.gz ;\ else \ # install old azure-powershell from PSGallery pwsh -Command Set-PSRepository -Name ${REPOSITORY} -InstallationPolicy Trusted && \ diff --git a/docker/Dockerfile-debian-11 b/docker/Dockerfile-debian-11 deleted file mode 100644 index 74840abbd682..000000000000 --- a/docker/Dockerfile-debian-11 +++ /dev/null @@ -1,50 +0,0 @@ -FROM mcr.microsoft.com/powershell:debian-11 - -ARG REPOSITORY=PSGallery -ARG MODULE=Az -ARG CONFIG=config -ARG AZURERM_CONTEXT_SETTINGS=AzureRmContextSettings.json -ARG AZURE=/root/.Azure -ARG VCS_REF="none" -ARG BUILD_DATE= -ARG VERSION= -ARG LATEST= -ARG BLOB_URL= -ARG IMAGE_NAME=mcr.microsoft.com/azure-powershell:${VERSION}-debian-11 - -ENV AZUREPS_HOST_ENVIRONMENT="dockerImage/${VERSION}-debian-11" - -LABEL maintainer="Azure PowerShell Team " \ - readme.md="http://aka.ms/azpsdockerreadme" \ - description="This Dockerfile will install the latest release of Azure PowerShell." \ - org.label-schema.build-date=${BUILD_DATE} \ - org.label-schema.usage="http://aka.ms/azpsdocker" \ - org.label-schema.url="http://aka.ms/azpsdockerreadme" \ - org.label-schema.vcs-url="https://github.com/Azure/azure-powershell" \ - org.label-schema.name="azure powershell" \ - org.label-schema.vendor="Azure PowerShell" \ - org.label-schema.version=${VERSION} \ - org.label-schema.schema-version="1.0" \ - org.label-schema.vcs-ref=${VCS_REF} \ - org.label-schema.docker.cmd="docker run --rm ${IMAGE_NAME} pwsh -c '\$PSVERSIONTABLE'" \ - org.label-schema.docker.cmd.devel="docker run -it --rm -e 'DebugPreference=Continue' ${IMAGE_NAME} pwsh" \ - org.label-schema.docker.cmd.test="currently not available" \ - org.label-schema.docker.cmd.help="docker run --rm ${IMAGE_NAME} pwsh -c Get-Help" - -RUN if [ "${LATEST}" = True ] ; then \ - # install latest azure-powershell from BLOB - pwsh -Command Invoke-WebRequest -uri ${BLOB_URL} -OutFile latest.tar.gz && \ - mkdir latest && \ - tar -zxvf ./latest.tar.gz -C ./latest && \ - pwsh -Command ./latest/InstallModule.ps1 -Scope AllUsers ;\ - else \ - # install old azure-powershell from PSGallery - pwsh -Command Set-PSRepository -Name ${REPOSITORY} -InstallationPolicy Trusted && \ - pwsh -Command Install-Module -Name ${MODULE} -RequiredVersion ${VERSION} -Scope AllUsers -Repository ${REPOSITORY} && \ - pwsh -Command Set-PSRepository -Name ${REPOSITORY} -InstallationPolicy Untrusted ;\ - fi - -# create AzureRmContextSettings.json before it was generated -COPY ${CONFIG}/${AZURERM_CONTEXT_SETTINGS} ${AZURE}/${AZURERM_CONTEXT_SETTINGS} - -CMD [ "pwsh" ] \ No newline at end of file diff --git a/docker/Dockerfile-debian-12 b/docker/Dockerfile-debian-12 index 6f243ec5bd77..e506274a9523 100644 --- a/docker/Dockerfile-debian-12 +++ b/docker/Dockerfile-debian-12 @@ -1,4 +1,5 @@ FROM mcr.microsoft.com/powershell:debian-12 +RUN apt-get update && apt-get upgrade -y && apt-get clean && rm -rf /var/lib/apt/lists/* ARG REPOSITORY=PSGallery ARG MODULE=Az @@ -36,7 +37,9 @@ RUN if [ "${LATEST}" = True ] ; then \ pwsh -Command Invoke-WebRequest -uri ${BLOB_URL} -OutFile latest.tar.gz && \ mkdir latest && \ tar -zxvf ./latest.tar.gz -C ./latest && \ - pwsh -Command ./latest/InstallModule.ps1 -Scope AllUsers ;\ + pwsh -Command ./latest/InstallModule.ps1 -Scope AllUsers &&\ + rm -fr latest &&\ + rm -f latest.tar.gz ;\ else \ # install old azure-powershell from PSGallery pwsh -Command Set-PSRepository -Name ${REPOSITORY} -InstallationPolicy Trusted && \ diff --git a/docker/Dockerfile-mariner-2 b/docker/Dockerfile-mariner-2 index 1b32a691c10c..033c814f05b5 100644 --- a/docker/Dockerfile-mariner-2 +++ b/docker/Dockerfile-mariner-2 @@ -1,4 +1,5 @@ FROM mcr.microsoft.com/powershell:mariner-2.0 +RUN tdnf update -y && tdnf upgrade -y && tdnf clean all ARG REPOSITORY=PSGallery ARG MODULE=Az @@ -38,7 +39,9 @@ RUN if [ "${LATEST}" = True ] ; then \ tdnf install -y tar gzip && \ tdnf clean all && \ tar -zxvf ./latest.tar.gz -C ./latest && \ - pwsh -Command ./latest/InstallModule.ps1 -Scope AllUsers ;\ + pwsh -Command ./latest/InstallModule.ps1 -Scope AllUsers &&\ + rm -fr latest &&\ + rm -f latest.tar.gz ;\ else \ # install old azure-powershell from PSGallery pwsh -Command Set-PSRepository -Name ${REPOSITORY} -InstallationPolicy Trusted && \ diff --git a/docker/Dockerfile-mariner-2-arm64 b/docker/Dockerfile-mariner-2-arm64 index b4bedd643eae..168e056a95e9 100644 --- a/docker/Dockerfile-mariner-2-arm64 +++ b/docker/Dockerfile-mariner-2-arm64 @@ -1,4 +1,5 @@ FROM mcr.microsoft.com/powershell:mariner-2.0-arm64 +RUN tdnf update -y && tdnf upgrade -y && tdnf clean all ARG REPOSITORY=PSGallery ARG MODULE=Az @@ -38,7 +39,9 @@ RUN if [ "${LATEST}" = True ] ; then \ tdnf install -y tar gzip && \ tdnf clean all && \ tar -zxvf ./latest.tar.gz -C ./latest && \ - pwsh -Command ./latest/InstallModule.ps1 -Scope AllUsers ;\ + pwsh -Command ./latest/InstallModule.ps1 -Scope AllUsers &&\ + rm -fr latest &&\ + rm -f latest.tar.gz ;\ else \ # install old azure-powershell from PSGallery pwsh -Command Set-PSRepository -Name ${REPOSITORY} -InstallationPolicy Trusted && \ diff --git a/docker/Dockerfile-ubi-8 b/docker/Dockerfile-ubi-8 index b031aedda39c..3b3fd3bef8d4 100644 --- a/docker/Dockerfile-ubi-8 +++ b/docker/Dockerfile-ubi-8 @@ -1,4 +1,5 @@ FROM mcr.microsoft.com/powershell:ubi-8 +RUN yum update -y && yum clean all ARG REPOSITORY=PSGallery ARG MODULE=Az @@ -36,7 +37,9 @@ RUN if [ "${LATEST}" = True ] ; then \ pwsh -Command Invoke-WebRequest -uri ${BLOB_URL} -OutFile latest.tar.gz && \ mkdir latest && \ tar -zxvf ./latest.tar.gz -C ./latest && \ - pwsh -Command ./latest/InstallModule.ps1 -Scope AllUsers ;\ + pwsh -Command ./latest/InstallModule.ps1 -Scope AllUsers &&\ + rm -fr latest &&\ + rm -f latest.tar.gz ;\ else \ # install old azure-powershell from PSGallery pwsh -Command Set-PSRepository -Name ${REPOSITORY} -InstallationPolicy Trusted && \ diff --git a/docker/Dockerfile-ubi-9 b/docker/Dockerfile-ubi-9 index b32ff11dedc4..9217a80d1ea2 100644 --- a/docker/Dockerfile-ubi-9 +++ b/docker/Dockerfile-ubi-9 @@ -1,4 +1,5 @@ FROM mcr.microsoft.com/powershell:ubi-9 +RUN dnf update -y && dnf clean all ARG REPOSITORY=PSGallery ARG MODULE=Az @@ -36,7 +37,9 @@ RUN if [ "${LATEST}" = True ] ; then \ pwsh -Command Invoke-WebRequest -uri ${BLOB_URL} -OutFile latest.tar.gz && \ mkdir latest && \ tar -zxvf ./latest.tar.gz -C ./latest && \ - pwsh -Command ./latest/InstallModule.ps1 -Scope AllUsers ;\ + pwsh -Command ./latest/InstallModule.ps1 -Scope AllUsers &&\ + rm -fr latest &&\ + rm -f latest.tar.gz ;\ else \ # install old azure-powershell from PSGallery pwsh -Command Set-PSRepository -Name ${REPOSITORY} -InstallationPolicy Trusted && \ diff --git a/docker/Dockerfile-ubuntu-20.04 b/docker/Dockerfile-ubuntu-20.04 index 99cf7f61a02c..675bebc2e770 100644 --- a/docker/Dockerfile-ubuntu-20.04 +++ b/docker/Dockerfile-ubuntu-20.04 @@ -1,4 +1,5 @@ FROM mcr.microsoft.com/powershell:ubuntu-20.04 +RUN apt-get update && apt-get upgrade -y && apt-get clean && rm -rf /var/lib/apt/lists/* ARG REPOSITORY=PSGallery ARG MODULE=Az @@ -36,7 +37,9 @@ RUN if [ "${LATEST}" = True ] ; then \ pwsh -Command Invoke-WebRequest -uri ${BLOB_URL} -OutFile latest.tar.gz && \ mkdir latest && \ tar -zxvf ./latest.tar.gz -C ./latest && \ - pwsh -Command ./latest/InstallModule.ps1 -Scope AllUsers ;\ + pwsh -Command ./latest/InstallModule.ps1 -Scope AllUsers &&\ + rm -fr latest &&\ + rm -f latest.tar.gz ;\ else \ # install old azure-powershell from PSGallery pwsh -Command Set-PSRepository -Name ${REPOSITORY} -InstallationPolicy Trusted && \ diff --git a/docker/Dockerfile-ubuntu-22.04 b/docker/Dockerfile-ubuntu-22.04 index 4827a514b01c..659e662a6b6b 100644 --- a/docker/Dockerfile-ubuntu-22.04 +++ b/docker/Dockerfile-ubuntu-22.04 @@ -1,4 +1,5 @@ FROM mcr.microsoft.com/powershell:ubuntu-22.04 +RUN apt-get update && apt-get upgrade -y && apt-get clean && rm -rf /var/lib/apt/lists/* ARG REPOSITORY=PSGallery ARG MODULE=Az @@ -37,6 +38,8 @@ RUN if [ "${LATEST}" = True ] ; then \ mkdir latest && \ tar -zxvf ./latest.tar.gz -C ./latest && \ pwsh -Command ./latest/InstallModule.ps1 -Scope AllUsers;\ + rm -fr latest &&\ + rm -f latest.tar.gz ;\ else \ # install old azure-powershell from PSGallery pwsh -Command Set-PSRepository -Name ${REPOSITORY} -InstallationPolicy Trusted && \