Skip to content

Commit e1c7769

Browse files
committed
Update buildscript to amazonami 2023
1 parent 41e9038 commit e1c7769

File tree

2 files changed

+20
-54
lines changed

2 files changed

+20
-54
lines changed

Diff for: Dockerfile

+18-31
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,39 @@
1-
FROM amazonlinux:2
1+
FROM amazonlinux:2023
22

3-
ARG LAMBDA_NODEJS_RELEASE="12.x"
3+
ARG LAMBDA_NODEJS_RELEASE="20.x"
44

5-
RUN yum groups mark install "Development Tools" \
6-
&& yum groups mark convert "Development Tools" \
7-
&& yum groupinstall -y "Development Tools" \
8-
&& yum -y install \
5+
RUN dnf -y groups mark install "Development Tools" \
6+
&& dnf -y groupinstall -y "Development Tools" \
7+
&& dnf -y install --allowerasing \
98
zip \
109
rsync \
11-
curl \
1210
which \
13-
mc \
14-
nano \
15-
coreutils \
16-
findutils
17-
18-
RUN curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo > /etc/yum.repos.d/yarn.repo \
19-
&& rpm -Uvh https://rpm.nodesource.com/pub_${LAMBDA_NODEJS_RELEASE}/el/7/x86_64/nodesource-release-el7-1.noarch.rpm
20-
21-
RUN yum -y install \
22-
yarn \
11+
findutils \
12+
curl \
13+
&& dnf -y clean all
14+
15+
RUN dnf install -y https://rpm.nodesource.com/pub_${LAMBDA_NODEJS_RELEASE}/nodistro/repo/nodesource-release-nodistro-1.noarch.rpm
16+
17+
RUN dnf -y install \
2318
nodejs \
2419
nasm \
2520
libjpeg-devel \
2621
libpng-devel \
2722
libtiff-devel \
28-
libgif-devel
23+
&& dnf -y clean all \
24+
&& npm i -g yarn
2925

30-
RUN yum -y install \
31-
python2 \
32-
python2-pip \
26+
RUN dnf -y install \
3327
python3 \
3428
python3-pip \
35-
python2-botocore \
36-
python2-boto3 \
3729
awscli \
3830
&& pip3 install --user \
3931
boto3 \
40-
botocore
41-
42-
RUN yum -y clean all
32+
botocore \
33+
&& dnf -y clean all
4334

4435
ENV LAMBDA_NODEJS_RELEASE="$LAMBDA_NODEJS_RELEASE" \
45-
LAMBDA_PYTHON2_RELEASE="2.7" \
46-
LAMBDA_PYTHON3_RELEASE="3.7" \
36+
LAMBDA_PYTHON3_RELEASE="3.9.x" \
4737
LAMBDA_BUILD_DIR="/var/app-local" \
4838
LAMBDA_WORK_DIR="/var/app"
4939

@@ -57,6 +47,3 @@ CMD chmod+x /bin/mageops-lambda-build \
5747
WORKDIR /var/app-local
5848

5949
ENTRYPOINT [ "/bin/mageops-lambda-build" ]
60-
61-
62-

Diff for: build.sh

+2-23
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ export LAMBDA_BUILD_HOOK_PRE_BUILD="${LAMBDA_PRE_BUILD_SCRIPT:-.lambda-build-hoo
1111
# Directory where custom shared libraries shall be placed in order to be loaded automatically.
1212
export LAMBDA_SHARED_LIB_DIR="${LAMBDA_SHARED_LIB_DIR:-${LAMBDA_WORK_DIR}/lib}"
1313

14-
export LAMBDA_PYTHON2_RELEASE="${LAMBDA_PYTHON2_RELEASE:--unknown}"
1514
export LAMBDA_PYTHON3_RELEASE="${LAMBDA_PYTHON3_RELEASE:--unknown}"
1615
export LAMBDA_NODEJS_RELEASE="${LAMBDA_NODEJS_RELEASE:--unknown}"
1716

@@ -36,24 +35,6 @@ function build_prepare() {
3635
"${LAMBDA_WORK_DIR}/" "${LAMBDA_BUILD_DIR}/"
3736
}
3837

39-
function build_python2() {
40-
LAMBDA_PACKAGE_NAME="${LAMBDA_PACKAGE_NAME:-$LAMBDA_NAME.python${LAMBDA_PYTHON2_RELEASE}}"
41-
42-
log_stage "Start python2 build"
43-
log_info "Python: $(python2 --version) ($(which python2))"
44-
log_info "Pip: $(pip2 --version) ($(which pip2))"
45-
46-
log_stage "Install python requirements"
47-
pip2 install -r requirements.txt -t "$LAMBDA_BUILD_DIR"
48-
49-
ls -al
50-
log_stage "Store list of installed python deps"
51-
PYTHONPATH="$LAMBDA_BUILD_DIR" pip2 freeze -r requirements.txt --local | tee "$LAMBDA_BUILD_DIR/requirements-built.txt"
52-
53-
log_stage "Precompile python sources"
54-
python2 -m compileall "$LAMBDA_BUILD_DIR/"
55-
}
56-
5738
function build_python3() {
5839
LAMBDA_PACKAGE_NAME="${LAMBDA_PACKAGE_NAME:-$LAMBDA_NAME.python${LAMBDA_PYTHON3_RELEASE}}"
5940

@@ -136,7 +117,6 @@ echo -e "\
136117
Usage: $(basename "$0") <env_type> <lambda_release_name> [custom_build_command]\n\
137118
\n\
138119
Available env types:\n\
139-
- python2 (python$LAMBDA_PYTHON2_RELEASE) \n\
140120
- python3 (python$LAMBDA_PYTHON3_RELEASE) \n\
141121
- nodejs (nodejs$LAMBDA_NODEJS_RELEASE) \n\
142122
- nodejs-yarn (nodejs$LAMBDA_NODEJS_RELEASE)\
@@ -158,10 +138,9 @@ export LAMBDA_CUSTOM_BUILD_CMD="$@"
158138
log_info "Host: $(uname -a)"
159139

160140
case "$LAMBDA_ENV_TYPE" in
161-
"python2") LAMBDA_BUILD="python2" ;;
162141
"python3") LAMBDA_BUILD="python3" ;;
163-
"nodejs") LAMBDA_BUILD="nodejs_npm" ;;
164-
"nodejs-yarn") LAMBDA_BUILD="nodejs_yarn" ;;
142+
"nodejs") LAMBDA_BUILD="nodejs_npm" ;;
143+
"nodejs-yarn") LAMBDA_BUILD="nodejs_yarn" ;;
165144
*) echo -e "Error - unknown lambda environemnt type: $LAMBDA_ENV_TYPE\n" >&2 && show_help && exit 9 ;;
166145
esac
167146

0 commit comments

Comments
 (0)