mirror of
https://github.com/swift-server/swift-aws-lambda-runtime.git
synced 2026-06-02 07:27:33 +00:00
This PR has been reworked. Instead of silently switching the default base image based on Swift version, we now: 1. **Keep Amazon Linux 2 as the default** base Docker image for the packager plugin 2. **Add a prominent deprecation warning** when AL2 is used (either via Docker or natively), informing developers that AL2 reaches End of Life on June 30, 2026 3. **Migrate all examples** (READMEs, SAM templates, scripts) to build and deploy on Amazon Linux 2023 (`provided.al2023` runtime + `--base-docker-image swift:amazonlinux2023`) 4. **Update documentation** (readme, quick-setup) with migration notes The warning includes the `--base-docker-image swift:6.3-amazonlinux2023` flag and reminds developers to use the `provided.al2023` runtime when deploying. After June 30, 2026, the default will switch to AL2023. --- <details> <summary>Original PR description (superseded)</summary> ~~Now that Docker Hub has official Swift images based on Amazon Linux 2023 (starting with 6.3), the packager plugin picks the right base image automatically depending on the Swift version:~~ ~~- Swift 6.3 and later: `swift:<version>-amazonlinux2023`~~ ~~- Earlier versions: `swift:<version>-amazonlinux2` (unchanged behavior)~~ ~~- No version specified (latest): defaults to `amazonlinux2023`~~ ~~When only a major version is provided (e.g. `--swift-version 6` without a minor), we conservatively treat it as 6.0 and use Amazon Linux 2, since we can't be sure it's 6.3+.~~ ~~Also added a verbose log line showing the resolved Swift version, Amazon Linux version, and final base image to help with debugging.~~ ~~The `--base-docker-image` flag still overrides everything as before.~~ </details> --------- Co-authored-by: Sébastien Stormacq <stormacq@amazon.lu>
58 lines
2.0 KiB
Bash
Executable File
58 lines
2.0 KiB
Bash
Executable File
#!/bin/bash
|
|
##===----------------------------------------------------------------------===##
|
|
##
|
|
## This source file is part of the SwiftAWSLambdaRuntime open source project
|
|
##
|
|
## Copyright (c) 2017-2024 Apple Inc. and the SwiftAWSLambdaRuntime project authors
|
|
## Licensed under Apache License v2.0
|
|
##
|
|
## See LICENSE.txt for license information
|
|
## See CONTRIBUTORS.txt for the list of SwiftAWSLambdaRuntime project authors
|
|
##
|
|
## SPDX-License-Identifier: Apache-2.0
|
|
##
|
|
##===----------------------------------------------------------------------===##
|
|
|
|
log() { printf -- "** %s\n" "$*" >&2; }
|
|
error() { printf -- "** ERROR: %s\n" "$*" >&2; }
|
|
fatal() { error "$@"; exit 1; }
|
|
|
|
test -n "${EXAMPLE:-}" || fatal "EXAMPLE unset"
|
|
|
|
# Use the local checkout of swift-aws-lambda-runtime instead of the published release
|
|
.github/workflows/scripts/use-local-deps.sh "Examples/${EXAMPLE}/Package.swift"
|
|
|
|
OUTPUT_DIR=.build/plugins/AWSLambdaPackager/outputs/AWSLambdaPackager
|
|
OUTPUT_FILE=${OUTPUT_DIR}/MyLambda/bootstrap
|
|
ZIP_FILE=${OUTPUT_DIR}/MyLambda/MyLambda.zip
|
|
|
|
pushd "Examples/${EXAMPLE}" || exit 1
|
|
|
|
# package the example (docker and swift toolchain are installed on the GH runner)
|
|
LAMBDA_USE_LOCAL_DEPS=../.. swift package archive --allow-network-connections docker --base-docker-image swift:amazonlinux2023 || exit 1
|
|
|
|
# did the plugin generated a Linux binary?
|
|
[ -f "${OUTPUT_FILE}" ]
|
|
file "${OUTPUT_FILE}" | grep --silent ELF
|
|
|
|
# did the plugin created a ZIP file?
|
|
[ -f "${ZIP_FILE}" ]
|
|
|
|
# does the ZIP file contain the bootstrap?
|
|
unzip -l "${ZIP_FILE}" | grep --silent bootstrap
|
|
|
|
# if EXAMPLE is ResourcesPackaging, check if the ZIP file contains hello.txt
|
|
if [ "$EXAMPLE" == "ResourcesPackaging" ]; then
|
|
echo "Checking if resource was added to the ZIP file"
|
|
unzip -l "${ZIP_FILE}" | grep --silent hello.txt
|
|
SUCCESS=$?
|
|
if [ "$SUCCESS" -eq 1 ]; then
|
|
log "❌ Resource not found." && exit 1
|
|
else
|
|
log "✅ Resource found."
|
|
fi
|
|
fi
|
|
|
|
echo "✅ The archive plugin is OK with example ${EXAMPLE}"
|
|
popd || exit 1
|