Skip to content

Instantly share code, notes, and snippets.

@lantrix
Last active February 17, 2020 08:01
Show Gist options
  • Save lantrix/1c0b23813213973857c276392eee74d1 to your computer and use it in GitHub Desktop.
Save lantrix/1c0b23813213973857c276392eee74d1 to your computer and use it in GitHub Desktop.
Build Environment for PowerShell 6 on AWS Lambda. It builds upon the Powershell alpine base image and installs the latest DotNet Core 2.1
FROM mcr.microsoft.com/powershell:6.2.3-alpine-3.8
RUN apk add --no-cache icu-libs
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false \
LC_ALL=en_US.UTF-8 \
LANG=en_US.UTF-8
# Install .NET Core SDK
ENV DOTNET_SDK_VERSION 2.1.803
RUN wget -q -O dotnet.tar.gz https://dotnetcli.blob.core.windows.net/dotnet/Sdk/$DOTNET_SDK_VERSION/dotnet-sdk-$DOTNET_SDK_VERSION-linux-musl-x64.tar.gz \
&& dotnet_sha512='df2026c23f082cf1c6426ac3938f41b7f3f9fd67ea0c975db4c58e0fe0e215481257a0884f7d670b8be622b34c005af6a104f9e50f186b13970c24b7a169d4c4' \
&& echo "$dotnet_sha512 dotnet.tar.gz" | sha512sum -c - \
&& mkdir -p /usr/share/dotnet \
&& tar -C /usr/share/dotnet -xzf dotnet.tar.gz \
&& ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet \
&& rm dotnet.tar.gz
# Enable correct mode for dotnet watch (only mode supported in a container)
ENV DOTNET_USE_POLLING_FILE_WATCHER=true \
# Skip extraction of XML docs - generally not useful within an image/container - helps performance
NUGET_XMLDOC_MODE=skip
# Trigger first run experience by running arbitrary cmd to populate local package cache
RUN dotnet help
RUN pwsh -Command "Install-Module AWSLambdaPSCore -Scope CurrentUser -Force"
RUN pwsh -Command "Install-Module -Name 'AWS.Tools.Common','AWS.Tools.Lambda','AWS.Tools.CloudFormation' -Force"
RUN apk add zip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment