Skip to content

Commit 124ef9f

Browse files
authored
Fix TDNF caching issues (#782)
1 parent 23d81a2 commit 124ef9f

File tree

3 files changed

+75
-74
lines changed

3 files changed

+75
-74
lines changed
Lines changed: 70 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,73 @@
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.3.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
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
45-
ARG PS_VERSION=7.3.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-
71-
# Use PowerShell as the default shell
72-
# Use array to avoid Docker prepending /bin/sh -c
73-
CMD [ "pwsh" ]
4+
FROM --platform=linux/arm64 mcr.microsoft.com/cbl-mariner/base/core:2.0 AS installer-env
5+
6+
# Define Args for the needed to add the package
7+
ARG PS_VERSION=7.3.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
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
45+
ARG PS_VERSION=7.3.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+
71+
# Use PowerShell as the default shell
72+
# Use array to avoid Docker prepending /bin/sh -c
73+
CMD [ "pwsh" ]

release/7-4/mariner2-arm64/docker/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ FROM setup-tdnf-repa AS installer-env
2020
# Download the Linux tar.gz and save it
2121
ADD ${PS_PACKAGE_URL} /tmp/powershell.rpm
2222

23-
RUN --mount=type=cache,target=/var/cache/tdnf \
24-
tdnf install -y \
23+
# 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
24+
RUN tdnf install -y \
2525
wget \
2626
awk \
2727
tar \

release/7-4/mariner2/docker/Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

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

6+
# Use the cache mount since this image does go into the final product
67
RUN --mount=type=cache,target=/var/cache/tdnf \
78
tdnf install -y mariner-repos-microsoft-preview \
89
&& tdnf makecache
@@ -20,8 +21,8 @@ FROM setup-tdnf-repa AS installer-env
2021
# Download the Linux tar.gz and save it
2122
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 \

0 commit comments

Comments
 (0)