forgejo/terraform/build_lambda.sh

26 lines
754 B
Bash
Raw Permalink Normal View History

#!/usr/bin/env bash
# Bundle the backup-verification function for the arm64 Lambda runtime.
# Runs on the Terraform worker during plan. HCP plan and apply use different
# workers, so the zip bytes are carried in the plan (see lambda.tf).
set -euo pipefail
ROOT="$(cd "$(dirname "$0")" && pwd)"
REPO="$(cd "${ROOT}/.." && pwd)"
SRC="${REPO}/lambda/backup-verification"
BUILD="${ROOT}/build/function"
rm -rf "${BUILD}"
mkdir -p "${BUILD}"
python3 -m pip install \
--target "${BUILD}" \
--platform manylinux2014_aarch64 \
--implementation cp \
--python-version 3.12 \
--only-binary=:all: \
--upgrade \
--requirement "${SRC}/requirements.txt"
cp "${SRC}/app.py" "${BUILD}/app.py"
find "${BUILD}" -type d -name __pycache__ -exec rm -rf {} +