-
Notifications
You must be signed in to change notification settings - Fork 156
Expand file tree
/
Copy pathDockerfile
More file actions
109 lines (94 loc) · 4.14 KB
/
Dockerfile
File metadata and controls
109 lines (94 loc) · 4.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# Docker image file that describes an Alpine3.8 image with PowerShell installed from .tar.gz file(s)
# Define arg(s) needed for the From statement
ARG fromTag=3.8
ARG imageRepo=alpine
FROM ${imageRepo}:${fromTag} AS installer-env
# Define Args for the needed to add the package
ARG PS_VERSION=6.2.0-preview.3
ARG PS_PACKAGE=powershell-${PS_VERSION}-linux-alpine-x64.tar.gz
ARG PS_PACKAGE_URL=https://github.com/PowerShell/PowerShell/releases/download/v${PS_VERSION}/${PS_PACKAGE}
ARG PS_INSTALL_VERSION=7-preview
# Download the Linux tar.gz and save it
ADD ${PS_PACKAGE_URL} /tmp/linux.tar.gz
# define the folder we will be installing PowerShell to
ENV PS_INSTALL_FOLDER=/opt/microsoft/powershell/$PS_INSTALL_VERSION
# Create the install folder
RUN mkdir -p ${PS_INSTALL_FOLDER}
# Unzip the Linux tar.gz
RUN tar zxf /tmp/linux.tar.gz -C ${PS_INSTALL_FOLDER}
# Start a new stage so we lose all the tar.gz layers from the final image
FROM ${imageRepo}:${fromTag}
# Copy only the files we need from the previous stage
COPY --from=installer-env ["/opt/microsoft/powershell", "/opt/microsoft/powershell"]
# Define Args and Env needed to create links
ARG PS_INSTALL_VERSION=7-preview
ENV PS_INSTALL_FOLDER=/opt/microsoft/powershell/$PS_INSTALL_VERSION \
\
# Define ENVs for Localization/Globalization
DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false \
LC_ALL=en_US.UTF-8 \
LANG=en_US.UTF-8 \
# set a fixed location for the Module analysis cache
PSModuleAnalysisCachePath=/var/cache/microsoft/powershell/PSModuleAnalysisCache/ModuleAnalysisCache
# Install dotnet dependencies and ca-certificates
RUN apk add --no-cache \
ca-certificates \
less \
\
# PSReadline/console dependencies
ncurses-terminfo-base \
\
# .NET Core dependencies
krb5-libs \
libgcc \
libintl \
libssl1.1 \
libstdc++ \
tzdata \
userspace-rcu \
zlib \
icu-libs \
&& apk -X https://dl-cdn.alpinelinux.org/alpine/edge/main add --no-cache \
lttng-ust \
\
# Create the pwsh symbolic link that points to powershell
&& ln -s ${PS_INSTALL_FOLDER}/pwsh /usr/bin/pwsh \
\
# Create the pwsh-preview symbolic link that points to powershell
&& ln -s ${PS_INSTALL_FOLDER}/pwsh /usr/bin/pwsh-preview \
# Give all user execute permissions and remove write permissions for others
&& chmod a+x,o-w ${PS_INSTALL_FOLDER}/pwsh \
# intialize powershell module cache
&& pwsh \
-NoLogo \
-NoProfile \
-Command " \
\$ErrorActionPreference = 'Stop' ; \
\$ProgressPreference = 'SilentlyContinue' ; \
while(!(Test-Path -Path \$env:PSModuleAnalysisCachePath)) { \
Write-Host "'Waiting for $env:PSModuleAnalysisCachePath'" ; \
Start-Sleep -Seconds 6 ; \
}"
# Define args needed only for the labels
ARG PS_VERSION=6.2.0-preview.2
ARG IMAGE_NAME=mcr.microsoft.com/powershell:preview-alpine-3.8
ARG VCS_REF="none"
# Add label last as it's just metadata and uses a lot of parameters
LABEL maintainer="PowerShell Team <powershellteam@hotmail.com>" \
readme.md="https://github.com/PowerShell/PowerShell/blob/master/docker/README.md" \
description="This Dockerfile will install the latest release of PowerShell." \
org.label-schema.usage="https://github.com/PowerShell/PowerShell/tree/master/docker#run-the-docker-image-you-built" \
org.label-schema.url="https://github.com/PowerShell/PowerShell/blob/master/docker/README.md" \
org.label-schema.vcs-url="https://github.com/PowerShell/PowerShell-Docker" \
org.label-schema.name="powershell" \
org.label-schema.vendor="PowerShell" \
org.label-schema.vcs-ref=${VCS_REF} \
org.label-schema.version=${PS_VERSION} \
org.label-schema.schema-version="1.0" \
org.label-schema.docker.cmd="docker run ${IMAGE_NAME} pwsh -c '$psversiontable'" \
org.label-schema.docker.cmd.devel="docker run ${IMAGE_NAME}" \
org.label-schema.docker.cmd.test="docker run ${IMAGE_NAME} pwsh -c Invoke-Pester" \
org.label-schema.docker.cmd.help="docker run ${IMAGE_NAME} pwsh -c Get-Help"
CMD [ "pwsh" ]