mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-13 01:41:59 +00:00
8a664e2cac
The recent update of urllib3 completely broken the world - https://github.com/urllib3/urllib3/issues/2168 - https://github.com/boto/botocore/issues/2926 - https://github.com/psf/requests/issues/6443
32 lines
953 B
Bash
32 lines
953 B
Bash
#!/usr/bin/env bash
|
|
set -xeo pipefail
|
|
|
|
WORKDIR=$(dirname "$0")
|
|
WORKDIR=$(readlink -f "${WORKDIR}")
|
|
cd "$WORKDIR"
|
|
|
|
PY_VERSION=3.10
|
|
PY_EXEC="python${PY_VERSION}"
|
|
DOCKER_IMAGE="python:${PY_VERSION}-slim"
|
|
LAMBDA_NAME=$(basename "$WORKDIR")
|
|
LAMBDA_NAME=${LAMBDA_NAME//_/-}
|
|
PACKAGE=lambda-package
|
|
rm -rf "$PACKAGE" "$PACKAGE".zip
|
|
mkdir "$PACKAGE"
|
|
cp app.py "$PACKAGE"
|
|
if [ -f requirements.txt ]; then
|
|
VENV=lambda-venv
|
|
rm -rf "$VENV" lambda-package.zip
|
|
docker run --rm --user="${UID}" --volume="${WORKDIR}:/lambda" --workdir="/lambda" "${DOCKER_IMAGE}" \
|
|
/bin/bash -c "
|
|
'$PY_EXEC' -m venv '$VENV' &&
|
|
source '$VENV/bin/activate' &&
|
|
pip install -r requirements.txt
|
|
"
|
|
cp -rT "$VENV/lib/$PY_EXEC/site-packages/" "$PACKAGE"
|
|
rm -r "$PACKAGE"/{pip,pip-*,setuptools,setuptools-*}
|
|
fi
|
|
( cd "$PACKAGE" && zip -9 -r ../"$PACKAGE".zip . )
|
|
|
|
aws lambda update-function-code --function-name "$LAMBDA_NAME" --zip-file fileb://"$PACKAGE".zip
|