forked from aws/aws-codebuild-docker-images
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
116 lines (100 loc) · 5.39 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# Copyright 2020-2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Amazon Software License (the "License"). You may not use this file except in compliance with the License.
# A copy of the License is located at
#
# http://aws.amazon.com/asl/
#
# or in the "license" file accompanying this file.
# This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied.
# See the License for the specific language governing permissions and limitations under the License.
FROM public.ecr.aws/lambda/provided:al2-x86_64 AS core
# Install SSH, and other utilities
RUN set -ex \
&& yum install -y -q openssh-clients \
&& mkdir ~/.ssh \
&& mkdir -p /opt/tools \
&& mkdir -p /codebuild/image/config \
&& touch ~/.ssh/known_hosts \
&& ssh-keyscan -t rsa,dsa,ed25519,ecdsa -H github.com >> ~/.ssh/known_hosts \
&& ssh-keyscan -t rsa,dsa,ed25519,ecdsa -H bitbucket.org >> ~/.ssh/known_hosts \
&& chmod 600 ~/.ssh/known_hosts \
&& rpm --import https://download.mono-project.com/repo/xamarin.gpg \
&& curl https://download.mono-project.com/repo/centos7-stable.repo | tee /etc/yum.repos.d/mono-centos7-stable.repo \
&& yum groupinstall -y -q "Development tools" \
&& yum install -y -q \
ImageMagick asciidoc bzip2-devel cvs cvsps \
docbook-dtds docbook-style-xsl e2fsprogs expat-devel expect fakeroot \
glib2-devel groff gzip icu iptables jq krb5-server libargon2-devel \
libcurl-devel libdb-devel libedit-devel libevent-devel libffi-devel \
libicu-devel libjpeg-devel libpng-devel libserf sqlite-devel \
libtidy-devel libunwind libwebp-devel libxml2-devel libxslt libxslt-devel \
libyaml-devel libzip-devel mariadb105-devel mercurial mlocate \
ncurses-devel oniguruma-devel openssl openssl-devel perl-DBD-SQLite \
perl-DBI perl-HTTP-Date perl-TimeDate perl-YAML-LibYAML \
postgresql-devel procps-ng python-configobj readline-devel rsync sgml-common \
subversion-perl tar tcl tk vim wget which xfsprogs xmlto xorg-x11-server-Xvfb xz-devel \
amazon-ecr-credential-helper \
&& rm /etc/yum.repos.d/mono-centos7-stable.repo
RUN /usr/sbin/useradd codebuild-user
ENV HOME="/tmp"
ENV LAMBDA_USER_HOME="/tmp/opt"
#=======================End of layer: core =================
FROM core AS tools
# Install Git
RUN set -ex \
&& GIT_VERSION=2.41.0 \
&& GIT_TAR_FILE=git-$GIT_VERSION.tar.gz \
&& GIT_SRC=https://github.com/git/git/archive/v${GIT_VERSION}.tar.gz \
&& curl -L -o $GIT_TAR_FILE $GIT_SRC \
&& tar zxf $GIT_TAR_FILE \
&& cd git-$GIT_VERSION \
&& make -j4 prefix=/usr \
&& make install prefix=/usr \
&& cd .. && rm -rf git-$GIT_VERSION \
&& rm -rf $GIT_TAR_FILE /tmp/*
# Install AWS CLI v2
# https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-linux.html
RUN curl https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip -o /tmp/awscliv2.zip \
&& unzip -q /tmp/awscliv2.zip -d /opt \
&& /opt/aws/install --update -i /usr/local/aws-cli -b /usr/local/bin \
&& rm /tmp/awscliv2.zip \
&& rm -rf /opt/aws \
&& aws --version
# Install AWS SAM CLI
RUN wget -nv https://github.com/aws/aws-sam-cli/releases/latest/download/aws-sam-cli-linux-x86_64.zip -O /tmp/samcli.zip \
&& unzip -q /tmp/samcli.zip -d /opt \
&& /opt/install --update -i /usr/local/sam-cli -b /usr/local/bin \
&& rm /tmp/samcli.zip /opt/install \
&& rm -rf /opt/aws-sam-cli-src \
&& sam --version
# AWS Tools
# 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
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/amd64/aws-iam-authenticator \
&& curl -sS -o /usr/local/bin/kubectl https://s3.us-west-2.amazonaws.com/amazon-eks/1.27.1/2023-04-19/bin/linux/amd64/kubectl \
&& curl -sS -o /usr/local/bin/ecs-cli https://s3.amazonaws.com/amazon-ecs-cli/ecs-cli-linux-amd64-latest \
&& curl -sS -L https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_Linux_amd64.tar.gz | tar xz -C /usr/local/bin \
&& chmod +x /usr/local/bin/kubectl /usr/local/bin/aws-iam-authenticator /usr/local/bin/ecs-cli /usr/local/bin/eksctl
#======================= End of layer: tools =================
FROM tools AS go_runtime
ENV GOLANG_VERSION="1.21.0" \
GOPATH="/go" \
GOLANG_DOWNLOAD_SHA256="d0398903a16ba2232b389fb31032ddf57cac34efda306a0eebac34f0965a0742"
ENV PATH="$GOPATH/bin:$LAMBDA_USER_HOME/go/bin:/usr/local/go/bin:$PATH"
RUN set -ex \
&& mkdir -p "$GOPATH/src" "$GOPATH/bin" \
&& chmod -R 777 "$GOPATH" \
&& wget "https://dl.google.com/go/go$GOLANG_VERSION.linux-amd64.tar.gz" -O /tmp/golang.tar.gz \
&& echo "$GOLANG_DOWNLOAD_SHA256 /tmp/golang.tar.gz" | sha256sum -c - \
&& tar -xzf /tmp/golang.tar.gz -C /usr/local \
&& go env -w GO111MODULE=auto \
&& rm -fr /tmp/* /var/tmp/*
ENV GOPATH="$GOPATH:$LAMBDA_USER_HOME/go" \
GOBIN="$LAMBDA_USER_HOME/go/bin" \
GOMODCACHE="$LAMBDA_USER_HOME/gomodcache"
#=======================End of layer: go_runtime =================
FROM go_runtime AS al_v1
COPY legal/bill_of_material.txt /usr/share/doc/bill_of_material.txt
# Cleanup
RUN rm -fr /tmp/*
#=======================End of layer: al_lambda_v1 =================