Skip to content

Instantly share code, notes, and snippets.

@yipo
Last active July 7, 2024 18:29
Show Gist options
  • Select an option

  • Save yipo/a3dcf0fa443fdabd01533ca78a88b7dd to your computer and use it in GitHub Desktop.

Select an option

Save yipo/a3dcf0fa443fdabd01533ca78a88b7dd to your computer and use it in GitHub Desktop.
Build a PowerShell Docker image based on Alpine Linux.
# syntax=docker/dockerfile:1
# Based on the installation instructions on the following page.
# https://learn.microsoft.com/powershell/scripting/install/install-alpine
FROM alpine/curl AS download
ARG package=https://github.com/PowerShell/PowerShell/releases/download/v7.4.3/powershell-7.4.3-linux-musl-x64.tar.gz
RUN curl -L $package -o /tmp/powershell.tar.gz
WORKDIR /tmp/release
RUN tar zxf /tmp/powershell.tar.gz
RUN chmod +x pwsh
FROM alpine:3.17
RUN apk add --no-cache ca-certificates less ncurses-terminfo-base \
krb5-libs libgcc libintl libssl1.1 libstdc++ tzdata userspace-rcu zlib icu-libs
RUN apk -X https://dl-cdn.alpinelinux.org/alpine/edge/main add --no-cache lttng-ust
COPY --from=download /tmp/release /opt/microsoft/powershell/7
RUN ln -s /opt/microsoft/powershell/7/pwsh /usr/bin/pwsh
ENTRYPOINT ["pwsh"]
@yipo
Copy link
Author

yipo commented Jul 7, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment