Skip to content

Commit 3427ddf

Browse files
authored
Sync Mariner changes from 7-4 to 7-5 (#784)
* Sync changes from 7-4 * Update release/7-5/mariner2-arm64/docker/Dockerfile
1 parent 5568c14 commit 3427ddf

File tree

2 files changed

+154
-153
lines changed

2 files changed

+154
-153
lines changed
Lines changed: 71 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,74 @@
11
# Copyright (c) Microsoft Corporation.
22
# Licensed under the MIT License.
33

4-
FROM mcr.microsoft.com/cbl-mariner/base/core:2.0.20221222-arm64 AS installer-env
5-
6-
# Define Args for the needed to add the package
7-
ARG PS_VERSION=7.4.0-preview.1
8-
ARG PS_PACKAGE=powershell-${PS_VERSION}-linux-arm64.tar.gz
9-
ARG PS_PACKAGE_URL=https://github.com/PowerShell/PowerShell/releases/download/v${PS_VERSION}/${PS_PACKAGE}
10-
ARG PS_INSTALL_VERSION=7-preview
11-
12-
# Define the folder we will be installing PowerShell to.
13-
ENV PS_INSTALL_FOLDER=/opt/microsoft/powershell/${PS_INSTALL_VERSION}
14-
15-
# Create the install folder.
16-
RUN mkdir -p ${PS_INSTALL_FOLDER}
17-
18-
ARG PS_PACKAGE_URL_BASE64
19-
20-
RUN --mount=type=cache,target=/var/cache/tdnf \
21-
tdnf update -y \
22-
&& tdnf install -y ca-certificates wget tar
23-
24-
RUN echo 'in task' \
25-
&& if [ -n "${PS_PACKAGE_URL_BASE64}" ]; then \
26-
echo 'using base64' \
27-
&& export url=$(echo "${PS_PACKAGE_URL_BASE64}" | base64 --decode -); \
28-
else \
29-
echo 'using unencoded' \
30-
&& export url="${PS_PACKAGE_URL}"; \
31-
fi \
32-
&& echo "url: $url" \
33-
&& wget -O /tmp/powershell.tar.gz "$url" \
34-
&& echo 'task done'
35-
36-
RUN ls -l /tmp/powershell.tar.gz
37-
38-
# Unzip the linux powershell.tar.gz
39-
RUN tar zxf /tmp/powershell.tar.gz -C ${PS_INSTALL_FOLDER}
40-
41-
FROM mcr.microsoft.com/cbl-mariner/base/core:2.0.20221222-arm64 AS final-image
42-
43-
# Define Args and Env needed to create links
44-
ARG PS_INSTALL_VERSION=7-preview
45-
ARG PS_VERSION=7.4.0-preview.1
46-
47-
ENV PS_INSTALL_FOLDER=/opt/microsoft/powershell/$PS_INSTALL_VERSION \
48-
\
49-
# Define ENVs for Localization/Globalization
50-
DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false \
51-
LC_ALL=en_US.UTF-8 \
52-
LANG=en_US.UTF-8 \
53-
# set a fixed location for the Module analysis cache
54-
PSModuleAnalysisCachePath=/var/cache/microsoft/powershell/PSModuleAnalysisCache/ModuleAnalysisCache \
55-
POWERSHELL_DISTRIBUTION_CHANNEL=PSDocker-arm64v7-Mariner-2
56-
57-
# Copy only the files we need from the previous stage
58-
COPY --from=installer-env ["/opt/microsoft/powershell", "/opt/microsoft/powershell"]
59-
60-
RUN --mount=type=cache,target=/var/cache/tdnf,rw \
61-
tdnf update -y \
62-
&& tdnf install -y icu less openssh-clients ca-certificates dotnet-runtime-7.0 \
63-
&& tdnf upgrade -y \
64-
&& tdnf clean all
65-
66-
# Give all user execute permissions and remove write permissions for others
67-
RUN chmod a+x,o-w ${PS_INSTALL_FOLDER}/pwsh \
68-
# Create the pwsh symbolic link that points to powershell
69-
&& ln -s ${PS_INSTALL_FOLDER}/pwsh /usr/bin/pwsh \
70-
&& ln -s ${PS_INSTALL_FOLDER}/pwsh /usr/bin/pwsh-preview
71-
72-
# Use PowerShell as the default shell
73-
# Use array to avoid Docker prepending /bin/sh -c
74-
CMD [ "pwsh" ]
4+
FROM --platform=linux/arm64 mcr.microsoft.com/cbl-mariner/base/core:2.0 AS installer-eng
5+
6+
# Define Args for the needed to add the package
7+
ARG PS_VERSION=7.4.0-preview.1
8+
ARG PS_PACKAGE=powershell-${PS_VERSION}-linux-arm64.tar.gz
9+
ARG PS_PACKAGE_URL=https://github.com/PowerShell/PowerShell/releases/download/v${PS_VERSION}/${PS_PACKAGE}
10+
ARG PS_INSTALL_VERSION=7-preview
11+
12+
# Define the folder we will be installing PowerShell to.
13+
ENV PS_INSTALL_FOLDER=/opt/microsoft/powershell/${PS_INSTALL_VERSION}
14+
15+
# Create the install folder.
16+
RUN mkdir -p ${PS_INSTALL_FOLDER}
17+
18+
ARG PS_PACKAGE_URL_BASE64
19+
20+
RUN --mount=type=cache,target=/var/cache/tdnf \
21+
tdnf update -y \
22+
&& tdnf install -y ca-certificates wget tar
23+
24+
RUN echo 'in task' \
25+
&& if [ -n "${PS_PACKAGE_URL_BASE64}" ]; then \
26+
echo 'using base64' \
27+
&& export url=$(echo "${PS_PACKAGE_URL_BASE64}" | base64 --decode -); \
28+
else \
29+
echo 'using unencoded' \
30+
&& export url="${PS_PACKAGE_URL}"; \
31+
fi \
32+
&& echo "url: $url" \
33+
&& wget -O /tmp/powershell.tar.gz "$url" \
34+
&& echo 'task done'
35+
36+
RUN ls -l /tmp/powershell.tar.gz
37+
38+
# Unzip the linux powershell.tar.gz
39+
RUN tar zxf /tmp/powershell.tar.gz -C ${PS_INSTALL_FOLDER}
40+
41+
FROM --platform=linux/arm64 mcr.microsoft.com/cbl-mariner/base/core:2.0 AS final-image
42+
43+
# Define Args and Env needed to create links
44+
ARG PS_INSTALL_VERSION=7-preview
45+
ARG PS_VERSION=7.4.0-preview.1
46+
47+
ENV PS_INSTALL_FOLDER=/opt/microsoft/powershell/$PS_INSTALL_VERSION \
48+
\
49+
# Define ENVs for Localization/Globalization
50+
DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false \
51+
LC_ALL=en_US.UTF-8 \
52+
LANG=en_US.UTF-8 \
53+
# set a fixed location for the Module analysis cache
54+
PSModuleAnalysisCachePath=/var/cache/microsoft/powershell/PSModuleAnalysisCache/ModuleAnalysisCache \
55+
POWERSHELL_DISTRIBUTION_CHANNEL=PSDocker-arm64v7-Mariner-2
56+
57+
# Copy only the files we need from the previous stage
58+
COPY --from=installer-env ["/opt/microsoft/powershell", "/opt/microsoft/powershell"]
59+
60+
RUN --mount=type=cache,target=/var/cache/tdnf,rw \
61+
tdnf update -y \
62+
&& tdnf install -y icu less openssh-clients ca-certificates dotnet-runtime-7.0 \
63+
&& tdnf upgrade -y \
64+
&& tdnf clean all
65+
66+
# Give all user execute permissions and remove write permissions for others
67+
RUN chmod a+x,o-w ${PS_INSTALL_FOLDER}/pwsh \
68+
# Create the pwsh symbolic link that points to powershell
69+
&& ln -s ${PS_INSTALL_FOLDER}/pwsh /usr/bin/pwsh \
70+
&& ln -s ${PS_INSTALL_FOLDER}/pwsh /usr/bin/pwsh-preview
71+
72+
# Use PowerShell as the default shell
73+
# Use array to avoid Docker prepending /bin/sh -c
74+
CMD [ "pwsh" ]

release/7-5/mariner2/docker/Dockerfile

Lines changed: 83 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -3,99 +3,100 @@
33

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

6-
RUN --mount=type=cache,target=/var/cache/tdnf \
7-
tdnf install -y mariner-repos-microsoft-preview \
8-
&& tdnf makecache
6+
# Use the cache mount since this image does go into the final product
7+
RUN --mount=type=cache,target=/var/cache/tdnf \
8+
tdnf install -y mariner-repos-microsoft-preview \
9+
&& tdnf makecache
910

10-
# Move to
11+
# Download packages into a container so they don't take up space in the final stage
1112
FROM setup-tdnf-repa AS installer-env
1213

13-
# Define Args for the needed to add the package
14-
ARG PS_VERSION=7.3.0-preview.8
15-
ARG PACKAGE_VERSION=7.3.0_preview.8
16-
ARG PS_PACKAGE=powershell-preview-${PACKAGE_VERSION}-1.cm.x86_64.rpm
17-
ARG PS_PACKAGE_URL=https://github.com/PowerShell/PowerShell/releases/download/v${PS_VERSION}/${PS_PACKAGE}
18-
ARG PS_INSTALL_VERSION=7-preview
14+
# Define Args for the needed to add the package
15+
ARG PS_VERSION=7.3.0-preview.8
16+
ARG PACKAGE_VERSION=7.3.0_preview.8
17+
ARG PS_PACKAGE=powershell-preview-${PACKAGE_VERSION}-1.cm.x86_64.rpm
18+
ARG PS_PACKAGE_URL=https://github.com/PowerShell/PowerShell/releases/download/v${PS_VERSION}/${PS_PACKAGE}
19+
ARG PS_INSTALL_VERSION=7-preview
1920

20-
# Download the Linux tar.gz and save it
21-
ADD ${PS_PACKAGE_URL} /tmp/powershell.rpm
21+
# Download the Linux tar.gz and save it
22+
ADD ${PS_PACKAGE_URL} /tmp/powershell.rpm
2223

23-
RUN --mount=type=cache,target=/var/cache/tdnf \
24-
tdnf install -y \
24+
# Don't use the cache mount since this image doesn't go into the final product and it causes issues with parralel operations with the next layer
25+
RUN tdnf install -y \
2526
wget \
2627
awk \
2728
tar \
2829
ca-certificates
2930

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

37-
RUN echo ${PS_PACKAGE_URL}
38+
RUN echo ${PS_PACKAGE_URL}
3839

39-
# Start a new stage so we lose all the tar.gz layers from the final image
40+
# Start a new stage so we lose all the package download layers from the final image
4041
FROM setup-tdnf-repa AS powershell
4142

42-
ARG PS_VERSION=7.3.0-preview.8
43-
ARG PS_INSTALL_VERSION=7-preview
44-
45-
# Define Args and Env needed to create links
46-
ARG PS_INSTALL_VERSION=7-preview
47-
ENV PS_INSTALL_FOLDER=/opt/microsoft/powershell/$PS_INSTALL_VERSION \
48-
\
49-
# Define ENVs for Localization/Globalization
50-
DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false \
51-
LC_ALL=en_US.UTF-8 \
52-
LANG=en_US.UTF-8 \
53-
# set a fixed location for the Module analysis cache
54-
PSModuleAnalysisCachePath=/var/cache/microsoft/powershell/PSModuleAnalysisCache/ModuleAnalysisCache \
55-
POWERSHELL_DISTRIBUTION_CHANNEL=PSDocker-Mariner-2.0
56-
57-
RUN --mount=type=cache,target=/var/cache/tdnf \
58-
# install dependencies
59-
tdnf install -y \
60-
# required for localization
61-
icu \
62-
# required for help in PowerShell
63-
less \
64-
# required for SSH
65-
openssh-clients \
66-
ca-certificates
67-
68-
# Install dependencies and clean up
69-
RUN --mount=type=cache,target=/var/cache/tdnf \
70-
tdnf upgrade -y \
71-
# clean cached data
72-
&& tdnf clean all
73-
74-
COPY --from=installer-env /usr/share/dotnet /usr/share/dotnet
75-
76-
RUN ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet
77-
78-
RUN --mount=type=cache,target=/var/cache/tdnf,rw \
79-
--mount=from=installer-env,target=/mnt/rpm,source=/tmp \
80-
rpm -i --nodeps /mnt/rpm/powershell.rpm
81-
82-
# Create the pwsh symbolic link that points to powershell
83-
RUN if [ -f "/opt/microsoft/powershell/7-preview/pwsh" ]; then ln -sf /opt/microsoft/powershell/7-preview/pwsh /usr/bin/pwsh; fi
84-
85-
# intialize powershell module cache
86-
# and disable telemetry for this ONE session
87-
RUN export POWERSHELL_TELEMETRY_OPTOUT=1 \
88-
&& pwsh \
89-
-NoLogo \
90-
-NoProfile \
91-
-Command " \
92-
\$ErrorActionPreference = 'Stop' ; \
93-
\$ProgressPreference = 'SilentlyContinue' ; \
94-
while(!(Test-Path -Path \$env:PSModuleAnalysisCachePath)) { \
95-
Write-Host "'Waiting for $env:PSModuleAnalysisCachePath'" ; \
96-
Start-Sleep -Seconds 6 ; \
97-
}"
98-
99-
# Use PowerShell as the default shell
100-
# Use array to avoid Docker prepending /bin/sh -c
101-
CMD [ "pwsh" ]
43+
ARG PS_VERSION=7.3.0-preview.8
44+
ARG PS_INSTALL_VERSION=7-preview
45+
46+
# Define Args and Env needed to create links
47+
ARG PS_INSTALL_VERSION=7-preview
48+
ENV PS_INSTALL_FOLDER=/opt/microsoft/powershell/$PS_INSTALL_VERSION \
49+
\
50+
# Define ENVs for Localization/Globalization
51+
DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false \
52+
LC_ALL=en_US.UTF-8 \
53+
LANG=en_US.UTF-8 \
54+
# set a fixed location for the Module analysis cache
55+
PSModuleAnalysisCachePath=/var/cache/microsoft/powershell/PSModuleAnalysisCache/ModuleAnalysisCache \
56+
POWERSHELL_DISTRIBUTION_CHANNEL=PSDocker-Mariner-2.0
57+
58+
RUN --mount=type=cache,target=/var/cache/tdnf \
59+
# install dependencies
60+
tdnf install -y \
61+
# required for localization
62+
icu \
63+
# required for help in PowerShell
64+
less \
65+
# required for SSH
66+
openssh-clients \
67+
ca-certificates
68+
69+
# Install dependencies and clean up
70+
RUN --mount=type=cache,target=/var/cache/tdnf \
71+
tdnf upgrade -y \
72+
# clean cached data
73+
&& tdnf clean all
74+
75+
COPY --from=installer-env /usr/share/dotnet /usr/share/dotnet
76+
77+
RUN ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet
78+
79+
RUN --mount=type=cache,target=/var/cache/tdnf,rw \
80+
--mount=from=installer-env,target=/mnt/rpm,source=/tmp \
81+
rpm -i --nodeps /mnt/rpm/powershell.rpm
82+
83+
# Create the pwsh symbolic link that points to powershell
84+
RUN if [ -f "/opt/microsoft/powershell/7-preview/pwsh" ]; then ln -sf /opt/microsoft/powershell/7-preview/pwsh /usr/bin/pwsh; fi
85+
86+
# intialize powershell module cache
87+
# and disable telemetry for this ONE session
88+
RUN export POWERSHELL_TELEMETRY_OPTOUT=1 \
89+
&& pwsh \
90+
-NoLogo \
91+
-NoProfile \
92+
-Command " \
93+
\$ErrorActionPreference = 'Stop' ; \
94+
\$ProgressPreference = 'SilentlyContinue' ; \
95+
while(!(Test-Path -Path \$env:PSModuleAnalysisCachePath)) { \
96+
Write-Host "'Waiting for $env:PSModuleAnalysisCachePath'" ; \
97+
Start-Sleep -Seconds 6 ; \
98+
}"
99+
100+
# Use PowerShell as the default shell
101+
# Use array to avoid Docker prepending /bin/sh -c
102+
CMD [ "pwsh" ]

0 commit comments

Comments
 (0)