Skip to content

Update mariner preview dotnet runtime install #741

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Mar 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions .vsts-ci/phase.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,19 @@ parameters:
jobs:
- job: ${{ parameters.jobName }}
dependsOn: ${{ parameters.dependsOn }}

strategy:
matrix: $[ ${{ parameters.matrix }} ]
maxParallel: ${{ parameters.maxParallel }}

variables:
ContinueOnError: ${{ parameters.continueonerror }}
scanType: Register
pool: ${{ parameters.pool }}
- group: Cache-ACR
- name: ContinueOnError
value: ${{ parameters.continueonerror }}
- name: scanType
value: Register
- name: pool
value: ${{ parameters.pool }}

pool:
${{ if eq(parameters['pool'],'')}}:
Expand Down Expand Up @@ -72,6 +77,11 @@ jobs:
Install-module Pester -Scope CurrentUser -Force -MaximumVersion 4.99
displayName: Install Pester
condition: and( succeededOrFailed(), ne(variables['Channel'],''))

- pwsh: |
docker login psdockercache.azurecr.io -u $(dockerCacheUserName) -p $(dockerCacheKey)
displayName: 'docker cache login'
condition: and( succeededOrFailed(), ne(variables['Channel'],''))

- pwsh: |
$extraParams = @{}
Expand Down
45 changes: 34 additions & 11 deletions release/7-4/mariner2/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

FROM mcr.microsoft.com/cbl-mariner/base/core:2.0 AS installer-env
FROM mcr.microsoft.com/cbl-mariner/base/core:2.0 AS setup-tdnf-repa

RUN --mount=type=cache,target=/var/cache/tdnf \
tdnf install -y mariner-repos-microsoft-preview \
&& tdnf makecache

# Move to
FROM setup-tdnf-repa AS installer-env

# Define Args for the needed to add the package
ARG PS_VERSION=7.3.0-preview.8
Expand All @@ -13,10 +20,24 @@ ARG PS_INSTALL_VERSION=7-preview
# Download the Linux tar.gz and save it
ADD ${PS_PACKAGE_URL} /tmp/powershell.rpm

RUN --mount=type=cache,target=/var/cache/tdnf \
tdnf install -y \
wget \
awk \
tar \
ca-certificates

RUN --mount=type=cache,target=/var/cache/tdnf \
--mount=type=cache,target=/installTmp \
cd /installTmp \
&& wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh \
&& chmod +x ./dotnet-install.sh \
&& ./dotnet-install.sh -Channel 8.0 -Quality preview -Runtime dotnet -InstallDir /usr/share/dotnet

RUN echo ${PS_PACKAGE_URL}

# Start a new stage so we lose all the tar.gz layers from the final image
FROM mcr.microsoft.com/cbl-mariner/base/core:2.0 AS powershell
FROM setup-tdnf-repa AS powershell

ARG PS_VERSION=7.3.0-preview.8
ARG PS_INSTALL_VERSION=7-preview
Expand All @@ -33,28 +54,30 @@ ENV PS_INSTALL_FOLDER=/opt/microsoft/powershell/$PS_INSTALL_VERSION \
PSModuleAnalysisCachePath=/var/cache/microsoft/powershell/PSModuleAnalysisCache/ModuleAnalysisCache \
POWERSHELL_DISTRIBUTION_CHANNEL=PSDocker-Mariner-2.0

# Install dependencies and clean up
RUN --mount=type=cache,target=/var/cache/tdnf \
tdnf install -y mariner-repos-microsoft-preview \
&& tdnf makecache \
# install dependencies
&& tdnf install -y \
tdnf install -y \
# required for localization
icu \
# required for help in PowerShell
less \
# required for SSH
openssh-clients \
ca-certificates \
dotnet-runtime-7.0 \
# upgrade packages
&& tdnf upgrade -y \
ca-certificates

# Install dependencies and clean up
RUN --mount=type=cache,target=/var/cache/tdnf \
tdnf upgrade -y \
# clean cached data
&& tdnf clean all

COPY --from=installer-env /usr/share/dotnet /usr/share/dotnet

RUN ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet

RUN --mount=type=cache,target=/var/cache/tdnf,rw \
--mount=from=installer-env,target=/mnt/rpm,source=/tmp \
rpm -i /mnt/rpm/powershell.rpm
rpm -i --nodeps /mnt/rpm/powershell.rpm

# Create the pwsh symbolic link that points to powershell
RUN if [ -f "/opt/microsoft/powershell/7-preview/pwsh" ]; then ln -sf /opt/microsoft/powershell/7-preview/pwsh /usr/bin/pwsh; fi
Expand Down
2 changes: 1 addition & 1 deletion unittests/generateMatrixJson.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Describe "build.ps1 -GenerateMatrixJson" {
$json = $vstsVariable.Value
{ $script:matrix += $json | ConvertFrom-Json -AsHashtable } | should -not -Throw
}
$script:matrix.count | Should -Be 3
$script:matrix.count | Should -Be 4
}
It "Should have multiple images" {
foreach($platforMatrix in $Script:matrix) {
Expand Down