-
Notifications
You must be signed in to change notification settings - Fork 26
/
Dockerfile.base_image
40 lines (30 loc) · 1.34 KB
/
Dockerfile.base_image
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
ARG FUNCTION_DIR="/app"
ARG AWS_LINUX_VERSION="2023"
ARG PYTHON_VERSION="3.11.10"
ARG ARCH=
FROM ${ARCH}amazonlinux:${AWS_LINUX_VERSION} as python-layer
ARG PYTHON_VERSION
# install python
RUN yum update -y \
&& yum groupinstall "Development Tools" -y \
&& yum install libffi-devel bzip2-devel wget openssl openssl-devel sqlite-devel coreutils -y --allowerasing
# breaking up this line to test building python using all the cores
RUN wget https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz \
&& tar -xf Python-${PYTHON_VERSION}.tgz \
&& cd Python-${PYTHON_VERSION}/ \
&& ./configure --enable-optimizations --enable-loadable-sqlite-extensions \
&& make -j install && ln -s /Python-${PYTHON_VERSION}/python /usr/bin/python \
&& python -m ensurepip --upgrade \
&& python -m pip install --upgrade pip
FROM ${ARCH}amazonlinux:${AWS_LINUX_VERSION} as build-layer
RUN yum install git shadow-utils -y
# copy python to the necessary locations
ARG PYTHON_VERSION
ARG FUNCTION_DIR="/app"
COPY --from=python-layer /Python-${PYTHON_VERSION} /Python-${PYTHON_VERSION}
COPY --from=python-layer /usr/local/bin /usr/local/bin
COPY --from=python-layer /usr/local/lib /usr/local/lib
RUN ln -s /Python-${PYTHON_VERSION}/python /usr/bin/python
RUN ln -s /Python-${PYTHON_VERSION}/pip3 /usr/bin/pip3
WORKDIR ${FUNCTION_DIR}
ENTRYPOINT [ "/bin/bash"]