@@ -9,40 +9,41 @@ ENV DEBIAN_FRONTEND=noninteractive
9
9
ARG RUNTIME_VERSION
10
10
11
11
# Install python and pip
12
- RUN apt-get update && \
13
- apt-get install -y \
14
- software-properties-common
12
+ RUN apt-get update && apt-get install -y software-properties-common
15
13
RUN add-apt-repository ppa:deadsnakes/ppa
16
14
RUN apt-get update && \
17
- apt-get install -y \
18
- curl \
19
- python${RUNTIME_VERSION} \
20
- python${RUNTIME_VERSION}-distutils
15
+ apt-get install -y \
16
+ curl \
17
+ python${RUNTIME_VERSION} \
18
+ python3-pip \
19
+ python3-virtualenv
20
+
21
+ # python3xx-distutils is needed for python < 3.12
22
+ RUN if [ $(echo ${RUNTIME_VERSION} | cut -d '.' -f 2) -lt 12 ]; then \
23
+ apt-get install -y python${RUNTIME_VERSION}-distutils; \
24
+ fi
25
+ RUN virtualenv --python /usr/bin/python${RUNTIME_VERSION} --no-setuptools /home/venv
26
+
21
27
22
- RUN ln -s /usr/bin/python${RUNTIME_VERSION} /usr/local/bin/python3
23
28
24
29
# Stage 2 - build function and dependencies
25
30
FROM python-image AS python-ubuntu-builder
26
31
27
32
ARG RUNTIME_VERSION
28
33
29
- RUN curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py"
30
- RUN python${RUNTIME_VERSION} get-pip.py
31
-
32
34
# Install aws-lambda-cpp build dependencies
33
- RUN apt-get update && \
34
- apt-get install -y \
35
- g++ \
36
- gcc \
37
- tar \
38
- gzip \
39
- make \
40
- cmake \
41
- autoconf \
42
- automake \
43
- libtool \
44
- libcurl4-openssl-dev \
45
- python${RUNTIME_VERSION}-dev
35
+ RUN apt-get install -y \
36
+ g++ \
37
+ gcc \
38
+ tar \
39
+ gzip \
40
+ make \
41
+ cmake \
42
+ autoconf \
43
+ automake \
44
+ libtool \
45
+ libcurl4-openssl-dev \
46
+ python${RUNTIME_VERSION}-dev
46
47
47
48
# Include global args in this stage of the build
48
49
ARG RIC_BUILD_DIR="/home/build/"
@@ -51,27 +52,28 @@ RUN mkdir -p ${RIC_BUILD_DIR}
51
52
# Copy function code and Runtime Interface Client .tgz
52
53
WORKDIR ${RIC_BUILD_DIR}
53
54
COPY . .
54
- RUN make init build test && \
55
+ RUN . /home/venv/bin/activate && \
56
+ pip install setuptools && \
57
+ make init build test && \
55
58
mv ./dist/awslambdaric-*.tar.gz ./dist/awslambdaric-test.tar.gz
56
59
60
+
61
+
57
62
# Include global args in this stage of the build
58
63
ARG FUNCTION_DIR="/home/app/"
59
64
# Create function directory
60
65
RUN mkdir -p ${FUNCTION_DIR}
61
66
# Copy function code
62
67
COPY tests/integration/test-handlers/echo/* ${FUNCTION_DIR}
63
- # Copy Runtime Interface Client .tgz
64
- RUN cp ./dist/awslambdaric-test.tar.gz ${FUNCTION_DIR}/awslambdaric-test.tar.gz
65
-
66
68
# Install the function's dependencies
67
69
WORKDIR ${FUNCTION_DIR}
68
- RUN python${RUNTIME_VERSION} -m pip install \
69
- awslambdaric-test.tar.gz \
70
- --target ${FUNCTION_DIR} && \
71
- rm awslambdaric-test.tar.gz
70
+ RUN . /home/venv/bin/activate && \
71
+ pip install ${RIC_BUILD_DIR}/dist/ awslambdaric-test.tar.gz --target ${FUNCTION_DIR}
72
+
73
+
72
74
73
75
74
- # Stage 4 - final runtime interface client image
76
+ # Stage 3 - final runtime interface client image
75
77
# Grab a fresh copy of the Python image
76
78
FROM python-image
77
79
0 commit comments