1+ # Copyright 2020-2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+ #
3+ # Licensed under the Amazon Software License (the "License"). You may not use this file except in compliance with the License.
4+ # A copy of the License is located at
5+ #
6+ # http://aws.amazon.com/asl/
7+ #
8+ # or in the "license" file accompanying this file.
9+ # This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied.
10+ # See the License for the specific language governing permissions and limitations under the License.
11+
12+ FROM public.ecr.aws/lambda/dotnet:8-arm64 AS core
13+
14+ # Install SSH, and other utilities
15+ RUN set -ex \
16+ && dnf install -y openssh-clients \
17+ && mkdir ~/.ssh \
18+ && mkdir -p /opt/tools \
19+ && mkdir -p /codebuild/image/config \
20+ && touch ~/.ssh/known_hosts \
21+ && ssh-keyscan -t rsa,dsa,ed25519,ecdsa -H github.com >> ~/.ssh/known_hosts \
22+ && ssh-keyscan -t rsa,dsa,ed25519,ecdsa -H bitbucket.org >> ~/.ssh/known_hosts \
23+ && chmod 600 ~/.ssh/known_hosts \
24+ && rpm --import https://download.mono-project.com/repo/xamarin.gpg \
25+ && curl https://download.mono-project.com/repo/centos7-stable.repo | tee /etc/yum.repos.d/mono-centos7-stable.repo \
26+ && dnf install -y make gcc gettext \
27+ && dnf install -y \
28+ ImageMagick asciidoc bzip2-devel cvs cvsps \
29+ docbook-dtds docbook-style-xsl e2fsprogs expat-devel expect fakeroot \
30+ glib2-devel groff gzip icu iptables jq krb5-server libargon2-devel \
31+ libcurl-devel libdb-devel libedit-devel libevent-devel libffi-devel \
32+ libicu-devel libjpeg-devel libpng-devel libserf sqlite-devel \
33+ libtidy-devel libunwind libwebp-devel libxml2-devel libxslt libxslt-devel \
34+ libyaml-devel libzip-devel mariadb105-devel mercurial mlocate \
35+ ncurses-devel oniguruma-devel openssl openssl-devel perl-DBD-SQLite \
36+ perl-DBI perl-HTTP-Date perl-TimeDate perl-YAML-LibYAML \
37+ postgresql-devel procps-ng python-configobj readline-devel rsync sgml-common \
38+ subversion-perl tar tcl tk vim wget which xfsprogs xmlto xorg-x11-server-Xvfb xz-devel \
39+ amazon-ecr-credential-helper \
40+ && rm /etc/yum.repos.d/mono-centos7-stable.repo
41+
42+ RUN /usr/sbin/useradd codebuild-user
43+
44+ ENV HOME="/tmp"
45+ ENV LAMBDA_USER_HOME="/tmp/opt"
46+ # =======================End of layer: core =================
47+
48+ FROM core AS tools
49+
50+ # Install Git
51+ RUN set -ex \
52+ && GIT_VERSION=2.44.0 \
53+ && GIT_TAR_FILE=git-$GIT_VERSION.tar.gz \
54+ && GIT_SRC=https://github.com/git/git/archive/v${GIT_VERSION}.tar.gz \
55+ && curl -L -o $GIT_TAR_FILE $GIT_SRC \
56+ && tar zxf $GIT_TAR_FILE \
57+ && cd git-$GIT_VERSION \
58+ && make -j4 prefix=/usr \
59+ && make install prefix=/usr \
60+ && cd .. && rm -rf git-$GIT_VERSION \
61+ && rm -rf $GIT_TAR_FILE /tmp/*
62+
63+ # Install AWS CLI v2
64+ # https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-linux.html
65+ RUN curl https://awscli.amazonaws.com/awscli-exe-linux-aarch64.zip -o /tmp/awscliv2.zip \
66+ && unzip -q /tmp/awscliv2.zip -d /opt \
67+ && /opt/aws/install --update -i /usr/local/aws-cli -b /usr/local/bin \
68+ && rm /tmp/awscliv2.zip \
69+ && rm -rf /opt/aws \
70+ && aws --version
71+
72+ # Install AWS SAM CLI
73+ RUN wget -nv https://github.com/aws/aws-sam-cli/releases/latest/download/aws-sam-cli-linux-arm64.zip -O /tmp/samcli.zip \
74+ && unzip -q /tmp/samcli.zip -d /opt \
75+ && /opt/install --update -i /usr/local/sam-cli -b /usr/local/bin \
76+ && rm /tmp/samcli.zip /opt/install \
77+ && rm -rf /opt/aws-sam-cli-src \
78+ && sam --version
79+
80+ # AWS Tools
81+ # https://docs.aws.amazon.com/eks/latest/userguide/install-aws-iam-authenticator.html https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ECS_CLI_installation.html
82+ RUN curl -sS -o /usr/local/bin/aws-iam-authenticator https://s3.us-west-2.amazonaws.com/amazon-eks/1.27.1/2023-04-19/bin/linux/arm64/aws-iam-authenticator \
83+ && curl -sS -o /usr/local/bin/kubectl https://s3.us-west-2.amazonaws.com/amazon-eks/1.27.1/2023-04-19/bin/linux/arm64/kubectl \
84+ && curl -sS -o /usr/local/bin/ecs-cli https://s3.amazonaws.com/amazon-ecs-cli/ecs-cli-linux-arm64-latest \
85+ && curl -sS -L https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_Linux_arm64.tar.gz | tar xz -C /usr/local/bin \
86+ && chmod +x /usr/local/bin/kubectl /usr/local/bin/aws-iam-authenticator /usr/local/bin/ecs-cli /usr/local/bin/eksctl
87+ # ======================= End of layer: tools =================
88+
89+ FROM tools AS dotnet_runtime
90+
91+ ENV DOTNET_SDK_VERSION "8.0.204"
92+ ENV DOTNET_SDK_DOWNLOAD_URL "https://dotnetcli.blob.core.windows.net/dotnet/Sdk/$DOTNET_SDK_VERSION/dotnet-sdk-$DOTNET_SDK_VERSION-linux-arm64.tar.gz"
93+ ENV DOTNET_SDK_DOWNLOAD_SHA512 "7000b559efe502e9a799e9fccb6bccc2e39eb21331d6cb2be54f389e357436b84f5ccbcc73245df647749ee32d27f7fb8b7737d449312f0db7dd3409f8e12443"
94+ ENV DOTNET_DIR "/var/lang/bin"
95+
96+ RUN set -ex \
97+ && curl -SL $DOTNET_SDK_DOWNLOAD_URL --output dotnet.tar.gz \
98+ && echo "$DOTNET_SDK_DOWNLOAD_SHA512 dotnet.tar.gz" | sha512sum -c - \
99+ && tar -zxf dotnet.tar.gz -C $DOTNET_DIR \
100+ && rm dotnet.tar.gz
101+
102+ # Add .NET Core Global Tools install folder to PATH
103+ ENV DOTNET_CLI_HOME=$LAMBDA_USER_HOME \
104+ PATH="$LAMBDA_USER_HOME/.dotnet/tools:$PATH"
105+
106+ # Trigger the population of the local package cache
107+ ENV NUGET_XMLDOC_MODE skip
108+ ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT true
109+ RUN set -ex \
110+ && mkdir warmup \
111+ && cd warmup \
112+ && dotnet new \
113+ && cd .. \
114+ && rm -rf warmup \
115+ && rm -rf /tmp/NuGetScratch
116+
117+ # Install Powershell Core
118+ # See instructions at https://docs.microsoft.com/en-us/powershell/scripting/setup/installing-powershell-core-on-linux
119+ ENV POWERSHELL_VERSION 7.4.2
120+ ENV POWERSHELL_DOWNLOAD_URL https://github.com/PowerShell/PowerShell/releases/download/v$POWERSHELL_VERSION/powershell-$POWERSHELL_VERSION-linux-arm64.tar.gz
121+ ENV POWERSHELL_DOWNLOAD_SHA 006021694A9E0CE962457D23189E3CB88AE030863B221907F8FB891DF9497AEB
122+
123+ RUN set -ex \
124+ && curl -SL $POWERSHELL_DOWNLOAD_URL --output powershell.tar.gz \
125+ && echo "$POWERSHELL_DOWNLOAD_SHA powershell.tar.gz" | sha256sum -c - \
126+ && mkdir -p /opt/microsoft/powershell/$POWERSHELL_VERSION \
127+ && tar zxf powershell.tar.gz -C /opt/microsoft/powershell/$POWERSHELL_VERSION \
128+ && rm powershell.tar.gz \
129+ && ln -s /opt/microsoft/powershell/$POWERSHELL_VERSION/pwsh /usr/bin/pwsh \
130+ && pwsh --version
131+ # =======================End of layer: dotnet_runtime =================
132+
133+ FROM dotnet_runtime AS al_v1
134+
135+ COPY legal/bill_of_material.txt /usr/share/doc/bill_of_material.txt
136+
137+ # Cleanup
138+ RUN rm -fr /tmp/*
139+ # =======================End of layer: al_lambda_v1 =================
0 commit comments