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/java:21-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+ && dnf install -y \
26+ ImageMagick asciidoc bzip2-devel cvs cvsps \
27+ docbook-dtds docbook-style-xsl e2fsprogs expat-devel expect fakeroot \
28+ glib2-devel groff gzip icu iptables jq krb5-server libargon2-devel \
29+ libcurl-devel libdb-devel libedit-devel libevent-devel libffi-devel \
30+ libicu-devel libjpeg-devel libpng-devel libserf sqlite-devel \
31+ libtidy-devel libunwind libwebp-devel libxml2-devel libxslt libxslt-devel \
32+ libyaml-devel libzip-devel mariadb105-devel mercurial mlocate \
33+ ncurses-devel oniguruma-devel openssl openssl-devel perl-DBD-SQLite \
34+ perl-DBI perl-HTTP-Date perl-TimeDate perl-YAML-LibYAML \
35+ postgresql-devel procps-ng python-configobj readline-devel rsync sgml-common \
36+ subversion-perl tar tcl tk vim wget which xfsprogs xmlto xorg-x11-server-Xvfb xz-devel \
37+ amazon-ecr-credential-helper make gcc gettext
38+
39+ RUN /usr/sbin/useradd codebuild-user
40+
41+ ENV HOME="/tmp"
42+ ENV LAMBDA_USER_HOME="/tmp/opt"
43+ # =======================End of layer: core =================
44+
45+ FROM core AS tools
46+
47+ # Install Git
48+ RUN set -ex \
49+ && GIT_VERSION=2.41.0 \
50+ && GIT_TAR_FILE=git-$GIT_VERSION.tar.gz \
51+ && GIT_SRC=https://github.com/git/git/archive/v${GIT_VERSION}.tar.gz \
52+ && curl -L -o $GIT_TAR_FILE $GIT_SRC \
53+ && tar zxf $GIT_TAR_FILE \
54+ && cd git-$GIT_VERSION \
55+ && make -j4 prefix=/usr \
56+ && make install prefix=/usr \
57+ && cd .. && rm -rf git-$GIT_VERSION \
58+ && rm -rf $GIT_TAR_FILE /tmp/*
59+
60+ # Install AWS CLI v2
61+ # https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-linux.html
62+ RUN curl https://awscli.amazonaws.com/awscli-exe-linux-aarch64.zip -o /tmp/awscliv2.zip \
63+ && unzip -q /tmp/awscliv2.zip -d /opt \
64+ && /opt/aws/install --update -i /usr/local/aws-cli -b /usr/local/bin \
65+ && rm /tmp/awscliv2.zip \
66+ && rm -rf /opt/aws \
67+ && aws --version
68+
69+ # # Install AWS SAM CLI
70+ RUN dnf install python3 \
71+ && pip3 install aws-sam-cli \
72+ && sam --version
73+
74+ # AWS Tools
75+ # 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
76+ 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 \
77+ && 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 \
78+ && curl -sS -o /usr/local/bin/ecs-cli https://s3.amazonaws.com/amazon-ecs-cli/ecs-cli-linux-arm64-latest \
79+ && curl -sS -L https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_Linux_arm64.tar.gz | tar xz -C /usr/local/bin \
80+ && chmod +x /usr/local/bin/kubectl /usr/local/bin/aws-iam-authenticator /usr/local/bin/ecs-cli /usr/local/bin/eksctl
81+ # ======================= End of layer: tools =================
82+
83+ FROM tools AS java_runtime
84+
85+ ENV MAVEN_HOME="/opt/maven" \
86+ MAVEN_VERSION=3.9.4 \
87+ GRADLE_VERSION=8.2.1 \
88+ ANT_VERSION=1.10.13 \
89+ GRADLE_PATH="$SRC_DIR/gradle" \
90+ MAVEN_DOWNLOAD_SHA512="deaa39e16b2cf20f8cd7d232a1306344f04020e1f0fb28d35492606f647a60fe729cc40d3cba33e093a17aed41bd161fe1240556d0f1b80e773abd408686217e" \
91+ GRADLE_DOWNLOADS_SHA256="7c3ad722e9b0ce8205b91560fd6ce8296ac3eadf065672242fd73c06b8eeb6ee" \
92+ ANT_DOWNLOAD_SHA512="de4ac604629e39a86a306f0541adb3775596909ad92feb8b7de759b1b286417db24f557228737c8b902d6abf722d2ce5bb0c3baa3640cbeec3481e15ab1958c9"
93+
94+ ARG MAVEN_CONFIG_HOME="/root/.m2"
95+
96+ # Install Maven
97+ RUN set -ex \
98+ && mkdir -p $MAVEN_HOME \
99+ && curl -LSso /var/tmp/apache-maven-$MAVEN_VERSION-bin.tar.gz https://apache.org/dist/maven/maven-3/$MAVEN_VERSION/binaries/apache-maven-$MAVEN_VERSION-bin.tar.gz \
100+ && echo "$MAVEN_DOWNLOAD_SHA512 /var/tmp/apache-maven-$MAVEN_VERSION-bin.tar.gz" | sha512sum -c - \
101+ && tar xzvf /var/tmp/apache-maven-$MAVEN_VERSION-bin.tar.gz -C $MAVEN_HOME --strip-components=1 \
102+ && rm /var/tmp/apache-maven-$MAVEN_VERSION-bin.tar.gz \
103+ && /usr/sbin/update-alternatives --install /usr/bin/mvn mvn /opt/maven/bin/mvn 10000 \
104+ && mkdir -p $MAVEN_CONFIG_HOME \
105+ # Install Gradle
106+ && mkdir -p $GRADLE_PATH \
107+ && wget -nv "https://services.gradle.org/distributions/gradle-$GRADLE_VERSION-all.zip" -O "$GRADLE_PATH/gradle-$GRADLE_VERSION-all.zip" \
108+ && unzip "$GRADLE_PATH/gradle-$GRADLE_VERSION-all.zip" -d /usr/local \
109+ && echo "$GRADLE_DOWNLOADS_SHA256 $GRADLE_PATH/gradle-$GRADLE_VERSION-all.zip" | sha256sum -c - \
110+ && rm "$GRADLE_PATH/gradle-$GRADLE_VERSION-all.zip" \
111+ # Install default GRADLE_VERSION to path
112+ && ln -s /usr/local/gradle-$GRADLE_VERSION/bin/gradle /usr/bin/gradle \
113+ && rm -rf $GRADLE_PATH \
114+ # Install Ant
115+ && curl -LSso /var/tmp/apache-ant-$ANT_VERSION-bin.tar.gz https://archive.apache.org/dist/ant/binaries/apache-ant-$ANT_VERSION-bin.tar.gz \
116+ && echo "$ANT_DOWNLOAD_SHA512 /var/tmp/apache-ant-$ANT_VERSION-bin.tar.gz" | sha512sum -c - \
117+ && tar -xzf /var/tmp/apache-ant-$ANT_VERSION-bin.tar.gz -C /opt \
118+ && rm /var/tmp/apache-ant-$ANT_VERSION-bin.tar.gz \
119+ && /usr/sbin/update-alternatives --install /usr/bin/ant ant /opt/apache-ant-$ANT_VERSION/bin/ant 10000
120+
121+ COPY tools/runtime_configs/maven/settings.xml $MAVEN_HOME/conf/settings.xml
122+
123+ ENV GRADLE_USER_HOME $LAMBDA_USER_HOME/.gradle
124+ # =======================End of layer: java_runtime =================
125+
126+ FROM java_runtime AS al_v1
127+
128+ COPY legal/bill_of_material.txt /usr/share/doc/bill_of_material.txt
129+
130+ # Cleanup
131+ RUN rm -fr /tmp/*
132+ # =======================End of layer: al_lambda_v1 =================
0 commit comments