azure-powershell/docker/Dockerfile-mariner-2

55 строки
2.4 KiB
Plaintext

FROM mcr.microsoft.com/powershell:mariner-2.0
RUN tdnf update -y && tdnf upgrade -y && tdnf clean all
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}-mariner-2.0
ENV AZUREPS_HOST_ENVIRONMENT="dockerImage/${VERSION}-mariner-2.0"
LABEL maintainer="Azure PowerShell Team <azdevxps@microsoft.com>" \
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 && \
tdnf install -y tar gzip && \
tdnf clean all && \
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 && \
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" ]