Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update distros in README file #141

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ target:

.PHONY: init
init:
pip3 install -r requirements/base.txt -r requirements/dev.txt
pip3 install -r requirements/base.txt -r requirements/dev.txt --use-pep517

.PHONY: test
test: check-format
Expand All @@ -21,7 +21,7 @@ test-smoke: setup-codebuild-agent

.PHONY: test-integ
test-integ: setup-codebuild-agent
CODEBUILD_IMAGE_TAG=codebuild-agent tests/integration/codebuild-local/test_all.sh tests/integration/codebuild/.
CODEBUILD_IMAGE_TAG=codebuild-agent DISTRO="$(DISTRO)" tests/integration/codebuild-local/test_all.sh tests/integration/codebuild

.PHONY: check-security
check-security:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ The Python Runtime Interface Client package currently supports Python versions:
### Creating a Docker Image for Lambda with the Runtime Interface Client
First step is to choose the base image to be used. The supported Linux OS distributions are:

- Amazon Linux 2
- Amazon Linux (2 and 2023)
- Alpine
- CentOS
- Debian
Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from setuptools import Extension, find_packages, setup
from awslambdaric import __version__


def get_curl_extra_linker_flags():
# We do not want to build the dependencies during packaging
if platform.system() != "Linux" or os.getenv("BUILD") == "true":
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/codebuild-local/test_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ main() {

BUILDSPEC_YML_DIR="$1"
HAS_YML=0
for f in "$BUILDSPEC_YML_DIR"/*.yml ; do
for f in "$BUILDSPEC_YML_DIR"/*"$DISTRO"*.yml ; do
[ -f "$f" ] || continue;
do_one_yaml "$f"
HAS_YML=1
Expand Down
5 changes: 0 additions & 5 deletions tests/integration/codebuild/buildspec.os.amazonlinux.1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ batch:
- "1"
RUNTIME_VERSION:
- "3.7"
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12"
phases:
pre_build:
commands:
Expand Down
2 changes: 0 additions & 2 deletions tests/integration/codebuild/buildspec.os.amazonlinux.2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@ batch:
DISTRO_VERSION:
- "2"
RUNTIME_VERSION:
- "3.7"
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12"
phases:
pre_build:
commands:
Expand Down
108 changes: 108 additions & 0 deletions tests/integration/codebuild/buildspec.os.amazonlinux.2023.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
version: 0.2

env:
variables:
OS_DISTRIBUTION: amazonlinux
PYTHON_LOCATION: "/usr/local/bin/python3"
TEST_NAME: "aws-lambda-python-rtc-amazonlinux-test"
batch:
build-matrix:
static:
ignore-failure: false
env:
privileged-mode: true
dynamic:
env:
variables:
DISTRO_VERSION:
- "2023"
RUNTIME_VERSION:
- "3.12"
phases:
pre_build:
commands:
- export IMAGE_TAG="python-${OS_DISTRIBUTION}-${DISTRO_VERSION}:${RUNTIME_VERSION}"
- echo "Extracting and including the Runtime Interface Emulator"
- SCRATCH_DIR=".scratch"
- mkdir "${SCRATCH_DIR}"
- ARCHITECTURE=$(arch)
- >
if [[ "$ARCHITECTURE" == "x86_64" ]]; then
RIE="aws-lambda-rie"
elif [[ "$ARCHITECTURE" == "aarch64" ]]; then
RIE="aws-lambda-rie-arm64"
else
echo "Architecture $ARCHITECTURE is not currently supported."
exit 1
fi
- tar -xvf tests/integration/resources/${RIE}.tar.gz --directory "${SCRATCH_DIR}"
- >
cp "tests/integration/docker/Dockerfile.echo.${OS_DISTRIBUTION}" \
"${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp"
- >
echo "COPY ${SCRATCH_DIR}/${RIE} /usr/bin/${RIE}" >> \
"${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp"
- >
if [[ -z "${DOCKERHUB_USERNAME}" && -z "${DOCKERHUB_PASSWORD}" ]];
then
echo "DockerHub credentials not set as CodeBuild environment variables. Continuing without docker login."
else
echo "Performing DockerHub login . . ."
docker login -u $DOCKERHUB_USERNAME -p $DOCKERHUB_PASSWORD
fi
- echo "Building image ${IMAGE_TAG}"
- >
docker build . \
-f "${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp" \
-t "${IMAGE_TAG}" \
--build-arg RUNTIME_VERSION="${RUNTIME_VERSION}" \
--build-arg DISTRO_VERSION="${DISTRO_VERSION}" \
--build-arg ARCHITECTURE="${ARCHITECTURE}"
build:
commands:
- set -x
- echo "Running Image ${IMAGE_TAG}"
- docker network create "${TEST_NAME}-network"
- >
docker run \
--detach \
--name "${TEST_NAME}-app" \
--network "${TEST_NAME}-network" \
--entrypoint="" \
"${IMAGE_TAG}" \
sh -c "/usr/bin/${RIE} ${PYTHON_LOCATION} -m awslambdaric app.handler"
- sleep 2
- >
docker run \
--name "${TEST_NAME}-tester" \
--env "TARGET=${TEST_NAME}-app" \
--network "${TEST_NAME}-network" \
--entrypoint="" \
"${IMAGE_TAG}" \
sh -c 'curl -X POST "http://${TARGET}:8080/2015-03-31/functions/function/invocations" -d "{}" --max-time 10'
- actual="$(docker logs --tail 1 "${TEST_NAME}-tester" | xargs)"
- expected='success'
- |
echo "Response: ${actual}"
if [[ "$actual" != "$expected" ]]; then
echo "fail! runtime: $RUNTIME - expected output $expected - got $actual"
exit -1
fi
finally:
- |
echo "---------Container Logs: ${TEST_NAME}-app----------"
echo
docker logs "${TEST_NAME}-app" || true
echo
echo "---------------------------------------------------"
echo "--------Container Logs: ${TEST_NAME}-tester--------"
echo
docker logs "${TEST_NAME}-tester" || true
echo
echo "---------------------------------------------------"
- echo "Cleaning up..."
- docker stop "${TEST_NAME}-app" || true
- docker rm --force "${TEST_NAME}-app" || true
- docker stop "${TEST_NAME}-tester" || true
- docker rm --force "${TEST_NAME}-tester" || true
- docker network rm "${TEST_NAME}-network" || true
15 changes: 13 additions & 2 deletions tests/integration/docker/Dockerfile.echo.amazonlinux
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,16 @@ RUN yum install -y \
openssl-devel \
wget \
libffi-devel \
python3-setuptools \
sqlite-devel

# Python3.10+ requires openssl1.1.1+
RUN if [[ "${DISTRO_VERSION}" == "2" ]]; then \
yum install -y openssl11-devel openssl11 ; \
else \
yum install -y openssl-devel openssl ; \
fi

RUN RUNTIME_LATEST_VERSION=${RUNTIME_VERSION}.$(curl -s https://www.python.org/ftp/python/ | \
grep -oE "href=\"$(echo ${RUNTIME_VERSION} | sed "s/\\./\\\./g")\.[0-9]+" | \
cut -d. -f3 | \
Expand All @@ -32,8 +40,8 @@ RUN RUNTIME_LATEST_VERSION=${RUNTIME_VERSION}.$(curl -s https://www.python.org/f
done) \
&& tar -xzf Python-${RUNTIME_LATEST_VERSION}.tgz \
&& cd Python-${RUNTIME_LATEST_VERSION} \
&& ./configure --prefix=/usr/local --enable-shared \
&& make \
&& ./configure --prefix=/usr/local --enable-shared --with-openssl=/usr/ \
&& make -j $(nproc) \
&& make install \
&& ln -s /usr/local/bin/python${RUNTIME_VERSION} /usr/local/bin/python${RUNTIME_LATEST_VERSION}

Expand Down Expand Up @@ -78,6 +86,9 @@ RUN mkdir -p ${RIC_BUILD_DIR}
# Copy function code and Runtime Interface Client .tgz
WORKDIR ${RIC_BUILD_DIR}
COPY . .
RUN if [[ "${RUNTIME_VERSION}" == "3.12" ]]; then \
python${RUNTIME_VERSION} -m pip install setuptools ; \
fi
RUN make init build test && \
mv ./dist/awslambdaric-*.tar.gz ./dist/awslambdaric-test.tar.gz

Expand Down
Loading