-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_test_local
More file actions
executable file
·44 lines (35 loc) · 1.1 KB
/
Copy path_test_local
File metadata and controls
executable file
·44 lines (35 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env bash
#
# Run a lightweight hello-world Node.js check inside the project Docker image.
set -euo pipefail
IFS=$'\n\t'
if [[ ! -f ".env" ]]; then
echo "Missing .env file. Copy .env-template and configure required values." >&2
exit 1
fi
# shellcheck disable=SC1091
source .env
required_vars=(DOCKER_IMAGE_NAME DOCKER_IMAGE_TAG)
for var in "${required_vars[@]}"; do
if [[ -z "${!var:-}" ]]; then
echo "${var} must be set in .env" >&2
exit 1
fi
done
project_dir="$(pwd)"
image="${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG}"
lambda_arch="${TF_VAR_LAMBDA_ARCHITECTURE:-x86_64}"
platform_opt=(--platform linux/amd64)
if [[ "${lambda_arch}" == "arm64" ]]; then
platform_opt=(--platform linux/arm64)
fi
echo "Running hello-world test inside ${image} (${platform_opt[0]})"
hello_cmd=$'set -euo pipefail\nnode -v\nnode -e \'console.log("Lambda template hello world from " + process.version)\'\n'
set -x
docker run --rm --memory=1g "${platform_opt[@]}" \
--volume "${project_dir}:/app" \
--workdir /app \
"${image}" \
/bin/bash -lc "${hello_cmd}"
set +x
echo "Hello-world container test completed."