version: 0.2 env: variables: OS_DISTRIBUTION: alpine JAVA_BINARY_LOCATION: "/usr/bin/java" DOCKER_CLI_EXPERIMENTAL: "enabled" DOCKER_CLI_PLUGIN_DIR: "/root/.docker/cli-plugins" batch: build-matrix: static: ignore-failure: false env: privileged-mode: true dynamic: env: variables: DISTRO_VERSION: - "3.13" - "3.14" - "3.15" RUNTIME_VERSION: - "corretto11" PLATFORM: - "linux/amd64" - "linux/arm64/v8" phases: install: commands: - > 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 - aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/configure_multi_arch_env.sh pre_build: commands: # Log some environment variables for troubleshooting - (mvn -v) # Install events (dependency of serialization) - (cd aws-lambda-java-events && mvn install) # Install serialization (dependency of RIC) - (cd aws-lambda-java-serialization && mvn install) - (cd aws-lambda-java-runtime-interface-client && mvn install) - (cd aws-lambda-java-runtime-interface-client/test/integration/test-handler && mvn install) - export IMAGE_TAG="java-${OS_DISTRIBUTION}-${DISTRO_VERSION}:${RUNTIME_VERSION}" - echo "Extracting and including Runtime Interface Emulator" - SCRATCH_DIR=".scratch" - mkdir "${SCRATCH_DIR}" - > if [[ "$PLATFORM" == "linux/amd64" ]]; then RIE="aws-lambda-rie" elif [[ "$PLATFORM" == "linux/arm64/v8" ]]; then RIE="aws-lambda-rie-arm64" else echo "Platform $PLATFORM is not currently supported." exit 1 fi - tar -xvf aws-lambda-java-runtime-interface-client/test/integration/resources/${RIE}.tar.gz --directory "${SCRATCH_DIR}" - > cp "aws-lambda-java-runtime-interface-client/test/integration/docker/Dockerfile.function.${OS_DISTRIBUTION}" \ "${SCRATCH_DIR}/Dockerfile.function.${OS_DISTRIBUTION}.tmp" - > echo "RUN apk add curl" >> \ "${SCRATCH_DIR}/Dockerfile.function.${OS_DISTRIBUTION}.tmp" - > echo "COPY ${SCRATCH_DIR}/${RIE} /usr/bin/${RIE}" >> \ "${SCRATCH_DIR}/Dockerfile.function.${OS_DISTRIBUTION}.tmp" - echo "Building image ${IMAGE_TAG}" - > docker build . \ -f "${SCRATCH_DIR}/Dockerfile.function.${OS_DISTRIBUTION}.tmp" \ -t "${IMAGE_TAG}" \ --platform="${PLATFORM}" \ --build-arg RUNTIME_VERSION="${RUNTIME_VERSION}" \ --build-arg DISTRO_VERSION="${DISTRO_VERSION}" build: commands: - aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/run_invocation_test.sh finally: - aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/fetch_test_container_logs.sh - aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/clean_up.sh