Skip to content

Commit 50b2358

Browse files
committed
Write more env vars to lib file and give a better description of why we source the lib file
1 parent 9677cf5 commit 50b2358

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

packer/linux/conf/bin/bk-configure-docker.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,12 @@ trap '[[ $? = 0 ]] && on_exit' EXIT
2626
exec > >(tee -a /var/log/elastic-stack.log | logger -t user-data -s 2>/dev/console) 2>&1
2727

2828

29-
echo Reading variables from AMI creation...
29+
echo Sourcing /usr/local/lib/bk-configure-docker.sh...
30+
echo This file is written by the scripts in packer/scripts.
31+
echo Note that the path is /usr/local/lib, not /usr/local/bin.
32+
echo Contents of /usr/local/lib/bk-configure-docker.sh:
3033
# shellcheck disable=SC1091
31-
source /usr/local/lib/bk-configure-docker.sh
34+
tee /dev/stderr < /usr/local/lib/bk-configure-docker.sh | source /dev/stdin
3235

3336
if [[ "${DOCKER_USERNS_REMAP:-false}" == "true" ]]; then
3437
echo Configuring user namespace remapping...

packer/linux/scripts/install-docker.sh

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,22 @@ sudo cp /tmp/conf/bin/docker-compose /usr/local/bin/docker-compose
4747
sudo chmod +x /usr/local/bin/docker-compose
4848
docker-compose version
4949

50+
# Writing QEMU container version info to /usr/local/lib/bk-configure-docker.sh.
51+
# We only pull this image when we build the AMI. It will be run in
52+
# /usr/local/bin/bk-configure-docker.sh, but it needs to know the image digest
53+
# to make sure it does not pull in another image instead.
54+
# NOTE: the executable file is in /usr/local/bin and it sources as file of the
55+
# same name in /usr/local/lib. These are not the same file.
5056
# See https://docs.docker.com/build/building/multi-platform/
57+
58+
echo Contents of /usr/local/lib/bk-configure-docker.sh:
59+
cat <<'EOF' | sudo tee -a /usr/local/lib/bk-configure-docker.sh
5160
QEMU_BINFMT_VERSION=7.0.0-28
5261
QEMU_BINFMT_DIGEST=sha256:66e11bea77a5ea9d6f0fe79b57cd2b189b5d15b93a2bdb925be22949232e4e55
5362
QEMU_BINFMT_TAG="qemu-v${QEMU_BINFMT_VERSION}@${QEMU_BINFMT_DIGEST}"
63+
EOF
64+
# shellcheck disable=SC1091
65+
source /usr/local/lib/bk-configure-docker.sh
5466
sudo mkdir -p /usr/local/lib
55-
echo "QEMU_BINFMT_TAG=\"$QEMU_BINFMT_TAG\"" | sudo tee -a /usr/local/lib/bk-configure-docker.sh
5667
echo Pulling qemu binfmt for multiarch...
5768
sudo docker pull "tonistiigi/binfmt:${QEMU_BINFMT_TAG}"

0 commit comments

Comments
 (0)