Skip to content

Instantly share code, notes, and snippets.

@TylerLeonhardt
Last active December 11, 2020 22:53
Show Gist options
  • Save TylerLeonhardt/d6679fd6782d697d36cdb4d38f67ce56 to your computer and use it in GitHub Desktop.
Save TylerLeonhardt/d6679fd6782d697d36cdb4d38f67ce56 to your computer and use it in GitHub Desktop.
code-server, powershell and the PowerShell extension for vscode
FROM codercom/code-server
#
# Add PowerShell
#
ARG PS_VERSION=6.2.0
ARG PS_PACKAGE=powershell_${PS_VERSION}-1.ubuntu.18.04_amd64.deb
ARG PS_PACKAGE_URL=https://github.com/PowerShell/PowerShell/releases/download/v${PS_VERSION}/${PS_PACKAGE}
RUN echo ${PS_PACKAGE_URL}
# Download the Linux package and save it
ADD ${PS_PACKAGE_URL} /tmp/powershell.deb
# Define ENVs for Localization/Globalization
ENV 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 dependencies and clean up
RUN apt-get update \
&& apt-get install -y /tmp/powershell.deb \
&& apt-get install -y \
# less is required for help in powershell
less \
# requied to setup the locale
locales \
# required for SSL
ca-certificates \
gss-ntlmssp \
&& apt-get dist-upgrade -y \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& locale-gen $LANG && update-locale \
# remove powershell package
&& rm /tmp/powershell.deb \
# 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 ; \
}"
#
# Add PowerShell extension
#
ARG PS_EXTENSION_VERSION=1.12.0
ARG PS_EXTENSION_PACKAGE=powershell-v${PS_EXTENSION_VERSION}.vsix
ARG PS_EXTENSION_PACKAGE_URL=https://github.com/PowerShell/vscode-powershell/releases/download/v${PS_EXTENSION_VERSION}/${PS_EXTENSION_PACKAGE}
RUN echo ${PS_EXTENSION_PACKAGE_URL}
ADD ${PS_EXTENSION_PACKAGE_URL} /tmp/vscode-powershell.zip
RUN pwsh -NoLogo -NoProfile -Command " \
\$ErrorActionPreference = 'Stop' ; \
\$ProgressPreference = 'SilentlyContinue' ; \
Expand-Archive /tmp/vscode-powershell.zip /tmp/vscode-powershell/ ; \
\$null = New-Item -Force -ItemType Directory ~/.local/share/code-server/extensions/ ; \
Move-Item /tmp/vscode-powershell/extension \
~/.local/share/code-server/extensions/ms-vscode.powershell-${PS_EXTENSION_VERSION} ; \
Remove-Item -Recurse -Force /tmp/vscode-powershell/ \
"
ARG VCS_REF="none"
ARG IMAGE_NAME=tylerl0706/powershell-code-server:stable
LABEL maintainer="Tyler Leonhardt <[email protected]>" \
readme.md="https://github.com/TylerLeonhardt/powershell-code-server/blob/master/README.md" \
description="Coder.com's code-server, PowerShell, and the PowerShell extension for vscode - all in one container." \
org.label-schema.url="https://github.com/TylerLeonhardt/powershell-code-server" \
org.label-schema.vcs-url="https://github.com/TylerLeonhardt/powershell-code-server" \
org.label-schema.name="tylerleonhardt" \
org.label-schema.vendor="TylerLeonhardt" \
org.label-schema.version=${PS_EXTENSION_VERSION} \
org.label-schema.schema-version="1.0" \
org.label-schema.vcs-ref=${VCS_REF} \
org.label-schema.docker.cmd="docker run -t -p 127.0.0.1:8443:8443 -v '\${PWD}:/root/project' ${IMAGE_NAME} code-server --allow-http --no-auth"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment